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 14#if defined(__arm__) || defined(__mips__) 15# define ANDROID_ARM_CODEGEN 1 16#else 17# define ANDROID_ARM_CODEGEN 0 18#endif 19 20#if defined (__mips__) 21#define ASSEMBLY_SCRATCH_SIZE 4096 22#else 23#define ASSEMBLY_SCRATCH_SIZE 2048 24#endif 25 26using namespace android; 27 28class ScanlineAssembly : public Assembly { 29 AssemblyKey<needs_t> mKey; 30public: 31 ScanlineAssembly(needs_t needs, size_t size) 32 : Assembly(size), mKey(needs) { } 33 const AssemblyKey<needs_t>& key() const { return mKey; } 34}; 35 36static void ggl_test_codegen(uint32_t n, uint32_t p, uint32_t t0, uint32_t t1) 37{ 38#if ANDROID_ARM_CODEGEN 39 GGLContext* c; 40 gglInit(&c); 41 needs_t needs; 42 needs.n = n; 43 needs.p = p; 44 needs.t[0] = t0; 45 needs.t[1] = t1; 46 sp<ScanlineAssembly> a(new ScanlineAssembly(needs, ASSEMBLY_SCRATCH_SIZE)); 47 48#if defined(__arm__) 49 GGLAssembler assembler( new ARMAssembler(a) ); 50#endif 51 52#if defined(__mips__) 53 GGLAssembler assembler( new ArmToMipsAssembler(a) ); 54#endif 55 56 int err = assembler.scanline(needs, (context_t*)c); 57 if (err != 0) { 58 printf("error %08x (%s)\n", err, strerror(-err)); 59 } 60 gglUninit(c); 61#else 62 printf("This test runs only on ARM or MIPS\n"); 63#endif 64} 65 66int main(int argc, char** argv) 67{ 68 if (argc != 2) { 69 printf("usage: %s 00000117:03454504_00001501_00000000\n", argv[0]); 70 return 0; 71 } 72 uint32_t n; 73 uint32_t p; 74 uint32_t t0; 75 uint32_t t1; 76 sscanf(argv[1], "%08x:%08x_%08x_%08x", &p, &n, &t0, &t1); 77 ggl_test_codegen(n, p, t0, t1); 78 return 0; 79} 80