sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1 | |
| 2 | /*---------------------------------------------------------------*/ |
| 3 | /*--- ---*/ |
| 4 | /*--- This file (test_main.c) is ---*/ |
| 5 | /*--- Copyright (c) 2004 OpenWorks LLP. All rights reserved. ---*/ |
| 6 | /*--- ---*/ |
| 7 | /*---------------------------------------------------------------*/ |
| 8 | |
| 9 | #include <stdio.h> |
| 10 | #include <stdlib.h> |
| 11 | |
| 12 | #include "basictypes.h" |
| 13 | #include "ir_defs.h" |
sewardj | 2cd80dc | 2004-07-02 15:20:40 +0000 | [diff] [blame] | 14 | #include "host_regs.h" |
| 15 | #include "x86h_defs.h" |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 16 | |
| 17 | |
| 18 | /*---------------------------------------------------------------*/ |
| 19 | /*--- Test ---*/ |
| 20 | /*---------------------------------------------------------------*/ |
| 21 | |
| 22 | /* HACK */ |
| 23 | extern |
sewardj | 2cd80dc | 2004-07-02 15:20:40 +0000 | [diff] [blame] | 24 | HInstrArray* /* not really, but for the time being ... */ |
| 25 | iselBB ( IRBB* bb ); |
| 26 | |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 27 | |
| 28 | int main ( void ) |
| 29 | { |
sewardj | 2cd80dc | 2004-07-02 15:20:40 +0000 | [diff] [blame] | 30 | HInstrArray* vcode; |
| 31 | IRBB* bb; |
| 32 | IRTypeEnv* env = newIRTypeEnv(); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 33 | |
| 34 | IRTemp t1 = 1; |
| 35 | IRTemp t2 = 2; |
| 36 | |
| 37 | addToIRTypeEnv ( env, t1, Ity_I32 ); |
| 38 | addToIRTypeEnv ( env, t2, Ity_I32 ); |
| 39 | |
| 40 | IRStmt* s1 = IRStmt_Put(8,4, IRExpr_Const(IRConst_U32(99)) ); |
| 41 | IRStmt* s2 = IRStmt_Put(7,4, IRExpr_Binop(Iop_Add32, |
| 42 | IRExpr_Tmp(t1), |
| 43 | IRExpr_Const(IRConst_U32(55)))); |
| 44 | s1->link = s2; |
| 45 | |
| 46 | bb = mk_IRBB(env, s1, IRNext_UJump(IRConst_U32(-65565))); |
| 47 | |
| 48 | printf("bb is ...\n"); |
| 49 | ppIRBB(stdout, bb); |
| 50 | printf("\n"); |
| 51 | |
sewardj | 2cd80dc | 2004-07-02 15:20:40 +0000 | [diff] [blame] | 52 | vcode = iselBB(bb); |
| 53 | { |
| 54 | HInstrArray* rcode; |
| 55 | HReg rregs_to_use[4]; |
| 56 | rregs_to_use[0] = hregX86_EAX(); |
| 57 | rregs_to_use[1] = hregX86_EBX(); |
| 58 | rregs_to_use[2] = hregX86_ECX(); |
| 59 | rregs_to_use[3] = hregX86_EDX(); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 60 | |
sewardj | 2cd80dc | 2004-07-02 15:20:40 +0000 | [diff] [blame] | 61 | rcode = |
| 62 | doRegisterAllocation(vcode, 3, /* vregs */ |
| 63 | rregs_to_use, 4, /* rregs */ |
| 64 | NULL, /* ismove */ |
| 65 | getRegUsage_X86Instr, |
| 66 | mapRegs_X86Instr, |
| 67 | NULL, /* genspill */ |
| 68 | NULL /* genreload */ |
| 69 | ); |
| 70 | |
| 71 | |
| 72 | } |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 73 | return 0; |
| 74 | } |