1ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Copyright 2013, ARM Limited
2ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// All rights reserved.
3ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
4ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Redistribution and use in source and binary forms, with or without
5ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// modification, are permitted provided that the following conditions are met:
6ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
7ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   * Redistributions of source code must retain the above copyright notice,
8ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//     this list of conditions and the following disclaimer.
9ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   * Redistributions in binary form must reproduce the above copyright notice,
10ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//     this list of conditions and the following disclaimer in the documentation
11ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//     and/or other materials provided with the distribution.
12ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   * Neither the name of ARM Limited nor the names of its contributors may be
13ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//     used to endorse or promote products derived from this software without
14ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//     specific prior written permission.
15ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
16ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
17ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
27ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#ifndef VIXL_EXAMPLE_EXAMPLES_H_
28ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl# define VIXL_EXAMPLE_EXAMPLES_H_
29ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
30ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#include "a64/simulator-a64.h"
31ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#include "a64/debugger-a64.h"
32ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#include "a64/macro-assembler-a64.h"
33ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
34ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlusing namespace vixl;
35ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
36ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Generate a function with the following prototype:
37ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   uint64_t factorial(uint64_t n)
38ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
39ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// It provides an iterative implementation of the factorial computation.
40ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlvoid GenerateFactorial(MacroAssembler* masm);
41ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
42ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Generate a function with the following prototype:
43ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   uint64_t factorial_rec(uint64_t n)
44ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
45ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// It provides a recursive implementation of the factorial computation.
46ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlvoid GenerateFactorialRec(MacroAssembler* masm);
47ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
48ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Generate a function with the following prototype:
49ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   double add3_double(double x, double y, double z)
50ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
51ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// This example is intended to show the calling convention with double
52ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// floating point arguments.
53ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlvoid GenerateAdd3Double(MacroAssembler* masm);
54ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
55ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Generate a function with the following prototype:
56ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   double add4_double(uint64_t a, double b, uint64_t c, double d)
57ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
58ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// The generated function pictures the calling convention for functions
59ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// mixing integer and floating point arguments.
60ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlvoid GenerateAdd4Double(MacroAssembler* masm);
61ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
62ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Generate a function with the following prototype:
63ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   uint32_t sum_array(uint8_t* array, uint32_t size)
64ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
65ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// The generated function computes the sum of all the elements in
66ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// the given array.
67ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlvoid GenerateSumArray(MacroAssembler* masm);
68ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
69ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Generate a function with the following prototype:
70ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   int64_t abs(int64_t x)
71ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
72ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// The generated function computes the absolute value of an integer.
73ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlvoid GenerateAbs(MacroAssembler* masm);
74ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
75ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Generate a function with the following prototype:
76ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   uint64_t check_bounds(uint64_t value, uint64_t low, uint64_t high)
77ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
78ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// The goal of this example is to illustrate the use of conditional
79ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// instructions. The generated function will check that the given value is
80ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// contained within the given boundaries. It returns 1 if 'value' is between
81ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// 'low' and 'high' (ie. low <= value <= high).
82ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlvoid GenerateCheckBounds(MacroAssembler* masm);
83ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
84ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Generate a function which uses the stack to swap the content of the x0, x1,
85ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// x2 and x3 registers.
86ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlvoid GenerateSwap4(MacroAssembler* masm);
87ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
88ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Generate a function which swaps the content of w0 and w1.
89ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// This example demonstrates some interesting features of VIXL's stack
90ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// operations.
91ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlvoid GenerateSwapInt32(MacroAssembler* masm);
92ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
93ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// Generate a function with the following prototype:
94ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//   uint64_t demo_function(uint64_t x)
95ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl//
96ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl// This is the example used in doc/getting-started.txt
97ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixlvoid GenerateDemoFunction(MacroAssembler *masm);
98ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
99ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl
100ad96eda8944ab1c1ba55715c50d9d6f0a3ed1dcarmvixl#endif /* !VIXL_EXAMPLE_EXAMPLES_H_ */
101