sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 1 | |
| 2 | /*---------------------------------------------------------------*/ |
| 3 | /*--- ---*/ |
sewardj | 887a11a | 2004-07-05 17:26:47 +0000 | [diff] [blame] | 4 | /*--- This file (libvex_ir.h) is ---*/ |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 5 | /*--- Copyright (c) 2004 OpenWorks LLP. All rights reserved. ---*/ |
| 6 | /*--- ---*/ |
| 7 | /*---------------------------------------------------------------*/ |
| 8 | |
sewardj | 887a11a | 2004-07-05 17:26:47 +0000 | [diff] [blame] | 9 | #ifndef __LIBVEX_IR_H |
| 10 | #define __LIBVEX_IR_H |
sewardj | ac9af02 | 2004-07-05 01:15:34 +0000 | [diff] [blame] | 11 | |
sewardj | 887a11a | 2004-07-05 17:26:47 +0000 | [diff] [blame] | 12 | #include "libvex_basictypes.h" |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 13 | |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 14 | |
| 15 | /*---------------------------------------------------------------*/ |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 16 | /*--- Type definitions for the IR ---*/ |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 17 | /*---------------------------------------------------------------*/ |
| 18 | |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 19 | /* ------------------ Types ------------------ */ |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 20 | |
| 21 | typedef |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 22 | enum { Ity_INVALID=0x10FFF, |
| 23 | Ity_Bit=0x11000, |
sewardj | e05c42c | 2004-07-08 20:25:10 +0000 | [diff] [blame] | 24 | Ity_I8, Ity_I16, Ity_I32, Ity_I64 } |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 25 | IRType; |
| 26 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 27 | extern void ppIRType ( IRType ); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 28 | |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 29 | |
| 30 | /* ------------------ Constants ------------------ */ |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 31 | |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 32 | typedef |
sewardj | e8e9d73 | 2004-07-16 21:03:45 +0000 | [diff] [blame^] | 33 | enum { Ico_U8=0x12000, |
| 34 | Ico_U16, Ico_U32, Ico_U64 } |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 35 | IRConstTag; |
| 36 | |
| 37 | typedef |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 38 | struct _IRConst { |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 39 | IRConstTag tag; |
| 40 | union { |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 41 | UChar U8; |
| 42 | UShort U16; |
| 43 | UInt U32; |
| 44 | ULong U64; |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 45 | } Ico; |
| 46 | } |
| 47 | IRConst; |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 48 | |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 49 | extern IRConst* IRConst_U8 ( UChar ); |
| 50 | extern IRConst* IRConst_U16 ( UShort ); |
| 51 | extern IRConst* IRConst_U32 ( UInt ); |
| 52 | extern IRConst* IRConst_U64 ( ULong ); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 53 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 54 | extern void ppIRConst ( IRConst* ); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 55 | |
| 56 | |
| 57 | /* ------------------ Temporaries ------------------ */ |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 58 | |
sewardj | fbcaf33 | 2004-07-08 01:46:01 +0000 | [diff] [blame] | 59 | typedef UInt IRTemp; |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 60 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 61 | extern void ppIRTemp ( IRTemp ); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 62 | |
sewardj | fbcaf33 | 2004-07-08 01:46:01 +0000 | [diff] [blame] | 63 | #define INVALID_IRTEMP ((IRTemp)0xFFFFFFFF) |
| 64 | |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 65 | |
| 66 | /* ------------------ Binary and unary ops ------------------ */ |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 67 | |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 68 | typedef |
sewardj | 41f43bc | 2004-07-08 14:23:22 +0000 | [diff] [blame] | 69 | enum { |
| 70 | /* Do not change this ordering. The IR generators |
| 71 | rely on (eg) Iop_Add64 == IopAdd8 + 3. */ |
sewardj | e8e9d73 | 2004-07-16 21:03:45 +0000 | [diff] [blame^] | 72 | Iop_Add8=0x13000, |
sewardj | e05c42c | 2004-07-08 20:25:10 +0000 | [diff] [blame] | 73 | Iop_Add16, Iop_Add32, Iop_Add64, |
sewardj | 41f43bc | 2004-07-08 14:23:22 +0000 | [diff] [blame] | 74 | Iop_Sub8, Iop_Sub16, Iop_Sub32, Iop_Sub64, |
| 75 | Iop_Adc8, Iop_Adc16, Iop_Adc32, Iop_Adc64, |
| 76 | Iop_Sbb8, Iop_Sbb16, Iop_Sbb32, Iop_Sbb64, |
| 77 | /* Signless mul. MullS/MullU is elsewhere. */ |
| 78 | Iop_Mul8, Iop_Mul16, Iop_Mul32, Iop_Mul64, |
| 79 | Iop_Or8, Iop_Or16, Iop_Or32, Iop_Or64, |
| 80 | Iop_And8, Iop_And16, Iop_And32, Iop_And64, |
| 81 | Iop_Xor8, Iop_Xor16, Iop_Xor32, Iop_Xor64, |
| 82 | Iop_Shl8, Iop_Shl16, Iop_Shl32, Iop_Shl64, |
| 83 | Iop_Shr8, Iop_Shr16, Iop_Shr32, Iop_Shr64, |
| 84 | Iop_Sar8, Iop_Sar16, Iop_Sar32, Iop_Sar64, |
sewardj | e90ad6a | 2004-07-10 19:02:10 +0000 | [diff] [blame] | 85 | /* Integer comparisons. */ |
| 86 | Iop_CmpEQ8, Iop_CmpEQ16, Iop_CmpEQ32, Iop_CmpEQ64, |
| 87 | Iop_CmpNE8, Iop_CmpNE16, Iop_CmpNE32, Iop_CmpNE64, |
sewardj | 41f43bc | 2004-07-08 14:23:22 +0000 | [diff] [blame] | 88 | /* Tags for unary ops */ |
| 89 | Iop_Not8, Iop_Not16, Iop_Not32, Iop_Not64, |
sewardj | e87b484 | 2004-07-10 12:23:30 +0000 | [diff] [blame] | 90 | Iop_Neg8, Iop_Neg16, Iop_Neg32, Iop_Neg64, |
sewardj | 9690d92 | 2004-07-14 01:39:17 +0000 | [diff] [blame] | 91 | /* Widening multiplies */ |
| 92 | Iop_MullS8, Iop_MullS16, Iop_MullS32, |
| 93 | Iop_MullU8, Iop_MullU16, Iop_MullU32, |
| 94 | /* Ordering not important after here. */ |
| 95 | /* Division */ |
| 96 | Iop_DivModU64to32, // :: I64,I32 -> I64 |
| 97 | // of which lo half is div and hi half is mod |
| 98 | Iop_DivModS64to32, // ditto, signed |
| 99 | /* Widening conversions */ |
sewardj | 9334b0f | 2004-07-10 22:43:54 +0000 | [diff] [blame] | 100 | Iop_8Uto16, Iop_8Uto32, Iop_16Uto32, |
| 101 | Iop_8Sto16, Iop_8Sto32, Iop_16Sto32, |
sewardj | 9690d92 | 2004-07-14 01:39:17 +0000 | [diff] [blame] | 102 | /* 32 <-> 64 bit conversions */ |
| 103 | Iop_64LOto32, // :: I64 -> I32, low half |
| 104 | Iop_64HIto32, // :: I64 -> I32, high half |
| 105 | Iop_32HLto64, // :: (I32,I32) -> I64 |
sewardj | cf780b4 | 2004-07-13 18:42:17 +0000 | [diff] [blame] | 106 | /* 1-bit stuff */ |
sewardj | 77b86be | 2004-07-11 13:28:24 +0000 | [diff] [blame] | 107 | Iop_32to1, /* :: Ity_I32 -> Ity_Bit, just select bit[0] */ |
| 108 | Iop_1Uto8 /* :: Ity_Bit -> Ity_I8, unsigned widen */ |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 109 | } |
| 110 | IROp; |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 111 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 112 | extern void ppIROp ( IROp ); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 113 | |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 114 | |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 115 | /* ------------------ Expressions ------------------ */ |
| 116 | /* |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 117 | data Expr |
| 118 | = GET Int Int -- offset, size |
| 119 | | TMP Temp -- value of temporary |
| 120 | | BINOP Op Expr Expr -- binary op |
| 121 | | UNOP Op Expr -- unary op |
| 122 | | LDle Type Expr -- load of the given type, Expr:: 32 or 64 |
| 123 | | CONST Const -- 8/16/32/64-bit int constant |
| 124 | */ |
| 125 | typedef |
sewardj | e87b484 | 2004-07-10 12:23:30 +0000 | [diff] [blame] | 126 | enum { Iex_Get, Iex_Tmp, Iex_Binop, Iex_Unop, Iex_LDle, |
sewardj | eeb9ef8 | 2004-07-15 12:39:03 +0000 | [diff] [blame] | 127 | Iex_Const, Iex_CCall, Iex_Mux10 } |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 128 | IRExprTag; |
| 129 | |
| 130 | typedef |
| 131 | struct _IRExpr { |
| 132 | IRExprTag tag; |
| 133 | union { |
| 134 | struct { |
sewardj | fbcaf33 | 2004-07-08 01:46:01 +0000 | [diff] [blame] | 135 | Int offset; |
| 136 | IRType ty; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 137 | } Get; |
| 138 | struct { |
| 139 | IRTemp tmp; |
| 140 | } Tmp; |
| 141 | struct { |
| 142 | IROp op; |
| 143 | struct _IRExpr* arg1; |
| 144 | struct _IRExpr* arg2; |
| 145 | } Binop; |
| 146 | struct { |
| 147 | IROp op; |
| 148 | struct _IRExpr* arg; |
| 149 | } Unop; |
| 150 | struct { |
| 151 | IRType ty; |
| 152 | struct _IRExpr* addr; |
| 153 | } LDle; |
| 154 | struct { |
sewardj | 66f2f79 | 2004-06-30 16:37:16 +0000 | [diff] [blame] | 155 | IRConst* con; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 156 | } Const; |
sewardj | e87b484 | 2004-07-10 12:23:30 +0000 | [diff] [blame] | 157 | struct { |
| 158 | Char* name; |
| 159 | IRType retty; |
| 160 | struct _IRExpr** args; |
| 161 | } CCall; |
sewardj | eeb9ef8 | 2004-07-15 12:39:03 +0000 | [diff] [blame] | 162 | struct { |
| 163 | struct _IRExpr* cond; |
| 164 | struct _IRExpr* expr1; |
| 165 | struct _IRExpr* expr0; |
| 166 | } Mux10; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 167 | } Iex; |
| 168 | } |
| 169 | IRExpr; |
| 170 | |
sewardj | fbcaf33 | 2004-07-08 01:46:01 +0000 | [diff] [blame] | 171 | extern IRExpr* IRExpr_Get ( Int off, IRType ty ); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 172 | extern IRExpr* IRExpr_Tmp ( IRTemp tmp ); |
| 173 | extern IRExpr* IRExpr_Binop ( IROp op, IRExpr* arg1, IRExpr* arg2 ); |
| 174 | extern IRExpr* IRExpr_Unop ( IROp op, IRExpr* arg ); |
| 175 | extern IRExpr* IRExpr_LDle ( IRType ty, IRExpr* addr ); |
| 176 | extern IRExpr* IRExpr_Const ( IRConst* con ); |
sewardj | e87b484 | 2004-07-10 12:23:30 +0000 | [diff] [blame] | 177 | extern IRExpr* IRExpr_CCall ( Char* name, IRType retty, IRExpr** args ); |
sewardj | eeb9ef8 | 2004-07-15 12:39:03 +0000 | [diff] [blame] | 178 | extern IRExpr* IRExpr_Mux10 ( IRExpr* cond, IRExpr* expr1, IRExpr* expr0 ); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 179 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 180 | extern void ppIRExpr ( IRExpr* ); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 181 | |
sewardj | e87b484 | 2004-07-10 12:23:30 +0000 | [diff] [blame] | 182 | /* CCall info. The name is the C helper function; the backends |
| 183 | will look it up in a table of known helpers, to get the address. |
| 184 | |
| 185 | The args are a NULL-terminated array of arguments. The stated |
| 186 | return IRType, and the implied argument types, must match that |
| 187 | of the function being called well enough so that the back end |
| 188 | can actually generate correct code for the call. (too vague) |
| 189 | |
| 190 | The called function must satisfy the following: |
| 191 | |
| 192 | * no side effects -- must be a pure function |
| 193 | * it may not look at any of the guest state -- must depend |
| 194 | purely on passed parameters |
| 195 | * it may not access guest memory -- since that would |
| 196 | hide guest memory transactions from the instrumenters |
| 197 | */ |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 198 | |
| 199 | /* ------------------ Statements ------------------ */ |
| 200 | /* |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 201 | data Stmt |
| 202 | = PUT Int Int Expr -- offset, size, value |
| 203 | | TMP Temp Expr -- store value in Temp |
| 204 | | STle Expr Expr -- address (32 or 64 bit), value |
sewardj | 64e1d65 | 2004-07-12 14:00:46 +0000 | [diff] [blame] | 205 | | Exit Expr Const -- conditional exit from middle of BB |
| 206 | -- Const is destination guest addr |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 207 | */ |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 208 | typedef |
sewardj | 64e1d65 | 2004-07-12 14:00:46 +0000 | [diff] [blame] | 209 | enum { Ist_Put, Ist_Tmp, Ist_STle, Ist_Exit } |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 210 | IRStmtTag; |
| 211 | |
| 212 | typedef |
| 213 | struct _IRStmt { |
| 214 | IRStmtTag tag; |
| 215 | union { |
| 216 | struct { |
| 217 | Int offset; |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 218 | IRExpr* expr; |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 219 | } Put; |
| 220 | struct { |
| 221 | IRTemp tmp; |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 222 | IRExpr* expr; |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 223 | } Tmp; |
| 224 | struct { |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 225 | IRExpr* addr; |
| 226 | IRExpr* data; |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 227 | } STle; |
sewardj | 64e1d65 | 2004-07-12 14:00:46 +0000 | [diff] [blame] | 228 | struct { |
| 229 | IRExpr* cond; |
| 230 | IRConst* dst; |
| 231 | } Exit; |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 232 | } Ist; |
| 233 | struct _IRStmt* link; |
| 234 | } |
| 235 | IRStmt; |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 236 | |
sewardj | eeb9ef8 | 2004-07-15 12:39:03 +0000 | [diff] [blame] | 237 | extern IRStmt* IRStmt_Put ( Int off, IRExpr* value ); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 238 | extern IRStmt* IRStmt_Tmp ( IRTemp tmp, IRExpr* expr ); |
| 239 | extern IRStmt* IRStmt_STle ( IRExpr* addr, IRExpr* value ); |
sewardj | 64e1d65 | 2004-07-12 14:00:46 +0000 | [diff] [blame] | 240 | extern IRStmt* IRStmt_Exit ( IRExpr* cond, IRConst* dst ); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 241 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 242 | extern void ppIRStmt ( IRStmt* ); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 243 | |
sewardj | e90ad6a | 2004-07-10 19:02:10 +0000 | [diff] [blame] | 244 | /* Guards in Put: if NULL, the Put is always done. |
| 245 | If non-NULL, the expr must denote a value of Ity_Bit, and |
| 246 | the Put is only done if this evaluates to 1. The expression |
| 247 | to be stored (expr) will be evaluated regardless of what |
| 248 | the guard is. |
| 249 | */ |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 250 | |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 251 | /* ------------------ Basic Blocks ------------------ */ |
sewardj | 78c19df | 2004-07-12 22:49:27 +0000 | [diff] [blame] | 252 | |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 253 | /* This describes the unconditional jumps which implicitly happen at |
| 254 | the end of each basic block. Conditional jumps -- which can only |
| 255 | be done with the IRStmt_Exit statement -- are implicitly of the |
| 256 | Ijk_Boring kind. */ |
| 257 | |
sewardj | 78c19df | 2004-07-12 22:49:27 +0000 | [diff] [blame] | 258 | typedef |
| 259 | enum { |
sewardj | e8e9d73 | 2004-07-16 21:03:45 +0000 | [diff] [blame^] | 260 | Ijk_Boring=0x14000, /* not interesting; just goto next */ |
sewardj | 78c19df | 2004-07-12 22:49:27 +0000 | [diff] [blame] | 261 | Ijk_Call, /* guest is doing a call */ |
| 262 | Ijk_Ret, /* guest is doing a return */ |
| 263 | Ijk_ClientReq, /* do guest client req before continuing */ |
| 264 | Ijk_Syscall, /* do guest syscall before continuing */ |
| 265 | Ijk_Yield /* client is yielding to thread scheduler */ |
| 266 | } |
| 267 | IRJumpKind; |
| 268 | |
| 269 | extern void ppIRJumpKind ( IRJumpKind ); |
| 270 | |
| 271 | |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 272 | /* A bunch of statements, expressions, etc, are incomplete without an |
| 273 | environment indicating the type of each IRTemp. So this provides |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 274 | one. IR temporaries are really just unsigned ints and so this |
| 275 | provides an array, 0 .. n_types_used-1 of them. |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 276 | */ |
| 277 | typedef |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 278 | struct { |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 279 | IRType* types; |
| 280 | Int types_size; |
| 281 | Int types_used; |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 282 | } |
| 283 | IRTypeEnv; |
| 284 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 285 | extern void ppIRTypeEnv ( IRTypeEnv* ); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 286 | |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 287 | |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 288 | /* Basic blocks contain 4 fields: |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 289 | - A table giving a type for each temp |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 290 | - A list of statements |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 291 | - An expression of type 32 or 64 bits, depending on the |
| 292 | guest's word size, indicating the next destination. |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 293 | */ |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 294 | typedef |
| 295 | struct _IRBB { |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 296 | IRTypeEnv* tyenv; |
| 297 | IRStmt* stmts; |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 298 | IRExpr* next; |
| 299 | IRJumpKind jumpkind; |
sewardj | ac6b712 | 2004-06-27 01:03:57 +0000 | [diff] [blame] | 300 | } |
| 301 | IRBB; |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 302 | |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 303 | extern IRBB* mkIRBB ( IRTypeEnv*, IRStmt*, IRExpr*, IRJumpKind ); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 304 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 305 | extern void ppIRBB ( IRBB* ); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 306 | |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 307 | |
| 308 | /*---------------------------------------------------------------*/ |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 309 | /*--- Helper functions for the IR ---*/ |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 310 | /*---------------------------------------------------------------*/ |
| 311 | |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 312 | /* For messing with IR type environments */ |
| 313 | extern IRTypeEnv* newIRTypeEnv ( void ); |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 314 | extern IRTemp newIRTemp ( IRTypeEnv*, IRType ); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 315 | extern IRType lookupIRTypeEnv ( IRTypeEnv*, IRTemp ); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 316 | |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 317 | /* What is the type of this expression? */ |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 318 | extern IRType typeOfIRConst ( IRConst* ); |
| 319 | extern IRType typeOfIRExpr ( IRTypeEnv*, IRExpr* ); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 320 | |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 321 | /* Sanity check a BB of IR */ |
| 322 | extern void sanityCheckIRBB ( IRBB* bb, IRType guest_word_size ); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 323 | |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 324 | /* Is this any value actually in the enumeration 'IRType' ? */ |
| 325 | extern Bool isPlausibleType ( IRType ty ); |
| 326 | |
sewardj | 887a11a | 2004-07-05 17:26:47 +0000 | [diff] [blame] | 327 | #endif /* ndef __LIBVEX_IR_H */ |
sewardj | ac9af02 | 2004-07-05 01:15:34 +0000 | [diff] [blame] | 328 | |
| 329 | |
| 330 | /*---------------------------------------------------------------*/ |
sewardj | 887a11a | 2004-07-05 17:26:47 +0000 | [diff] [blame] | 331 | /*--- libvex_ir.h ---*/ |
sewardj | ac9af02 | 2004-07-05 01:15:34 +0000 | [diff] [blame] | 332 | /*---------------------------------------------------------------*/ |