• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <stdio.h>
2 #include <stdint.h>
3 
4 #include "private/pixelflinger/ggl_context.h"
5 
6 #include "buffer.h"
7 #include "scanline.h"
8 
9 #include "codeflinger/CodeCache.h"
10 #include "codeflinger/GGLAssembler.h"
11 #include "codeflinger/ARMAssembler.h"
12 #include "codeflinger/MIPSAssembler.h"
13 #include "codeflinger/Arm64Assembler.h"
14 
15 #if defined(__arm__) || defined(__mips__) || defined(__aarch64__)
16 #   define ANDROID_ARM_CODEGEN  1
17 #else
18 #   define ANDROID_ARM_CODEGEN  0
19 #endif
20 
21 #if defined (__mips__)
22 #define ASSEMBLY_SCRATCH_SIZE   4096
23 #elif defined(__aarch64__)
24 #define ASSEMBLY_SCRATCH_SIZE   8192
25 #else
26 #define ASSEMBLY_SCRATCH_SIZE   2048
27 #endif
28 
29 using namespace android;
30 
31 class ScanlineAssembly : public Assembly {
32     AssemblyKey<needs_t> mKey;
33 public:
ScanlineAssembly(needs_t needs,size_t size)34     ScanlineAssembly(needs_t needs, size_t size)
35         : Assembly(size), mKey(needs) { }
key() const36     const AssemblyKey<needs_t>& key() const { return mKey; }
37 };
38 
ggl_test_codegen(uint32_t n,uint32_t p,uint32_t t0,uint32_t t1)39 static void ggl_test_codegen(uint32_t n, uint32_t p, uint32_t t0, uint32_t t1)
40 {
41 #if ANDROID_ARM_CODEGEN
42     GGLContext* c;
43     gglInit(&c);
44     needs_t needs;
45     needs.n = n;
46     needs.p = p;
47     needs.t[0] = t0;
48     needs.t[1] = t1;
49     sp<ScanlineAssembly> a(new ScanlineAssembly(needs, ASSEMBLY_SCRATCH_SIZE));
50 
51 #if defined(__arm__)
52     GGLAssembler assembler( new ARMAssembler(a) );
53 #endif
54 
55 #if defined(__mips__) && !defined(__LP64__)
56     GGLAssembler assembler( new ArmToMipsAssembler(a) );
57 #endif
58 
59 #if defined(__aarch64__)
60     GGLAssembler assembler( new ArmToArm64Assembler(a) );
61 #endif
62 
63     int err = assembler.scanline(needs, (context_t*)c);
64     if (err != 0) {
65         printf("error %08x (%s)\n", err, strerror(-err));
66     }
67     gglUninit(c);
68 #else
69     printf("This test runs only on ARM, Arm64 or MIPS\n");
70 #endif
71 }
72 
main(int argc,char ** argv)73 int main(int argc, char** argv)
74 {
75     if (argc != 2) {
76         printf("usage: %s 00000117:03454504_00001501_00000000\n", argv[0]);
77         return 0;
78     }
79     uint32_t n;
80     uint32_t p;
81     uint32_t t0;
82     uint32_t t1;
83     sscanf(argv[1], "%08x:%08x_%08x_%08x", &p, &n, &t0, &t1);
84     ggl_test_codegen(n, p,  t0, t1);
85     return 0;
86 }
87