Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_SRC_GREENLAND_DEX_LANG_H_ |
| 18 | #define ART_SRC_GREENLAND_DEX_LANG_H_ |
| 19 | |
| 20 | #include "backend_types.h" |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 21 | #include "compiler_llvm/backend_types.h" |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 22 | #include "dalvik_reg.h" |
| 23 | #include "ir_builder.h" |
| 24 | |
| 25 | #include "dex_file.h" |
| 26 | #include "dex_instruction.h" |
| 27 | #include "invoke_type.h" |
| 28 | #include "macros.h" |
| 29 | |
| 30 | #include <vector> |
| 31 | |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 32 | #include <llvm/Module.h> |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 33 | #include <llvm/ADT/ArrayRef.h> |
| 34 | |
| 35 | namespace llvm { |
| 36 | class BasicBlock; |
| 37 | class Function; |
| 38 | class LLVMContext; |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 39 | class Type; |
| 40 | } |
| 41 | |
| 42 | namespace art { |
| 43 | class Compiler; |
| 44 | class OatCompilationUnit; |
| 45 | } |
| 46 | |
| 47 | namespace art { |
| 48 | namespace greenland { |
| 49 | |
| 50 | class DalvikReg; |
| 51 | class IntrinsicHelper; |
| 52 | |
| 53 | class DexLang { |
| 54 | public: |
| 55 | class Context { |
| 56 | private: |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 57 | llvm::Module& module_; |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 58 | IntrinsicHelper* intrinsic_helper_; |
| 59 | |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 60 | public: |
| 61 | Context(llvm::Module& module); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 62 | ~Context(); |
| 63 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 64 | inline llvm::LLVMContext& GetLLVMContext() |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 65 | { return module_.getContext(); } |
| 66 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 67 | inline llvm::Module& GetOutputModule() |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 68 | { return module_; } |
| 69 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 70 | inline IntrinsicHelper& GetIntrinsicHelper() |
| 71 | { return *intrinsic_helper_; } |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 72 | inline const IntrinsicHelper& GetIntrinsicHelper() const |
| 73 | { return *intrinsic_helper_; } |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 74 | |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 75 | private: |
| 76 | DISALLOW_COPY_AND_ASSIGN(Context); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | public: |
| 80 | DexLang(Context& context, Compiler& compiler, OatCompilationUnit& cunit); |
| 81 | |
| 82 | ~DexLang(); |
| 83 | |
| 84 | llvm::Function* Build(); |
| 85 | |
| 86 | inline IRBuilder& GetIRBuilder() { |
| 87 | return irb_; |
| 88 | } |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 89 | llvm::Value* AllocateDalvikReg(RegCategory cat, unsigned reg_idx); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 90 | |
| 91 | private: |
| 92 | Context& dex_lang_ctx_; |
| 93 | Compiler& compiler_; |
| 94 | OatCompilationUnit& cunit_; |
| 95 | |
| 96 | const DexFile* dex_file_; |
| 97 | const DexFile::CodeItem* code_item_; |
| 98 | DexCache* dex_cache_; |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 99 | uint32_t method_idx_; |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 100 | |
| 101 | llvm::LLVMContext& context_; |
| 102 | llvm::Module& module_; |
| 103 | IntrinsicHelper& intrinsic_helper_; |
| 104 | |
| 105 | IRBuilder irb_; |
| 106 | llvm::Function* func_; |
| 107 | |
| 108 | private: |
| 109 | //---------------------------------------------------------------------------- |
| 110 | // Basic Block Helper Functions |
| 111 | //---------------------------------------------------------------------------- |
| 112 | llvm::BasicBlock* reg_alloc_bb_; |
| 113 | llvm::BasicBlock* arg_reg_init_bb_; |
| 114 | |
| 115 | std::vector<llvm::BasicBlock*> basic_blocks_; |
| 116 | |
| 117 | llvm::BasicBlock* GetBasicBlock(unsigned dex_pc); |
| 118 | llvm::BasicBlock* CreateBasicBlockWithDexPC(unsigned dex_pc, |
| 119 | char const* postfix = NULL); |
| 120 | llvm::BasicBlock* GetNextBasicBlock(unsigned dex_pc); |
| 121 | |
| 122 | private: |
| 123 | //---------------------------------------------------------------------------- |
| 124 | // Register Helper Functions |
| 125 | //---------------------------------------------------------------------------- |
| 126 | std::vector<DalvikReg*> regs_; |
| 127 | |
| 128 | inline llvm::Value* EmitLoadDalvikReg(unsigned reg_idx, JType jty, |
| 129 | JTypeSpace space) { |
| 130 | DCHECK(regs_.at(reg_idx) != NULL); |
| 131 | return regs_[reg_idx]->GetValue(jty, space); |
| 132 | } |
| 133 | |
| 134 | inline llvm::Value* EmitLoadDalvikReg(unsigned reg_idx, char shorty, |
| 135 | JTypeSpace space) { |
| 136 | DCHECK(regs_.at(reg_idx) != NULL); |
| 137 | return EmitLoadDalvikReg(reg_idx, GetJTypeFromShorty(shorty), space); |
| 138 | } |
| 139 | |
| 140 | inline void EmitStoreDalvikReg(unsigned reg_idx, JType jty, JTypeSpace space, |
| 141 | llvm::Value* new_value) { |
| 142 | regs_[reg_idx]->SetValue(jty, space, new_value); |
| 143 | return; |
| 144 | } |
| 145 | |
| 146 | inline void EmitStoreDalvikReg(unsigned reg_idx, char shorty, |
| 147 | JTypeSpace space, llvm::Value* new_value) { |
| 148 | EmitStoreDalvikReg(reg_idx, GetJTypeFromShorty(shorty), space, new_value); |
| 149 | return; |
| 150 | } |
| 151 | |
| 152 | private: |
| 153 | //---------------------------------------------------------------------------- |
| 154 | // Return Value Related |
| 155 | //---------------------------------------------------------------------------- |
| 156 | // Hold the return value returned from the lastest invoke-* instruction |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 157 | DalvikReg* retval_reg_; |
| 158 | |
| 159 | llvm::Value* EmitLoadDalvikRetValReg(JType jty, JTypeSpace space) { |
| 160 | return retval_reg_->GetValue(jty, space); |
| 161 | } |
| 162 | |
| 163 | llvm::Value* EmitLoadDalvikRetValReg(char shorty, JTypeSpace space) { |
| 164 | return EmitLoadDalvikRetValReg(GetJTypeFromShorty(shorty), space); |
| 165 | } |
| 166 | |
| 167 | void EmitStoreDalvikRetValReg(JType jty, JTypeSpace space, |
| 168 | llvm::Value* new_value) { |
| 169 | retval_reg_->SetValue(jty, space, new_value); |
| 170 | return; |
| 171 | } |
| 172 | |
| 173 | void EmitStoreDalvikRetValReg(char shorty, JTypeSpace space, |
| 174 | llvm::Value* new_value) { |
| 175 | EmitStoreDalvikRetValReg(GetJTypeFromShorty(shorty), space, new_value); |
| 176 | return; |
| 177 | } |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 178 | |
| 179 | private: |
| 180 | //---------------------------------------------------------------------------- |
| 181 | // Exception Handling |
| 182 | //---------------------------------------------------------------------------- |
| 183 | std::vector<llvm::BasicBlock*> landing_pads_bb_; |
| 184 | llvm::BasicBlock* exception_unwind_bb_; |
| 185 | |
| 186 | // cur_try_item_offset caches the latest try item offset such that we don't |
| 187 | // have to call DexFile::FindCatchHandlerOffset(...) (using binary search) for |
| 188 | // every query of the try item for the given dex_pc. |
| 189 | int32_t cur_try_item_offset; |
| 190 | |
| 191 | int32_t GetTryItemOffset(unsigned dex_pc); |
| 192 | |
| 193 | llvm::BasicBlock* GetLandingPadBasicBlock(unsigned dex_pc); |
| 194 | |
| 195 | llvm::BasicBlock* GetUnwindBasicBlock(); |
| 196 | |
| 197 | void EmitBranchExceptionLandingPad(unsigned dex_pc); |
| 198 | |
| 199 | void EmitGuard_DivZeroException(unsigned dex_pc, |
| 200 | llvm::Value* denominator, |
| 201 | JType op_jty); |
| 202 | |
| 203 | void EmitGuard_NullPointerException(unsigned dex_pc, llvm::Value* object); |
| 204 | |
| 205 | void EmitGuard_ArrayIndexOutOfBoundsException(unsigned dex_pc, |
| 206 | llvm::Value* array, |
| 207 | llvm::Value* index); |
| 208 | |
| 209 | void EmitGuard_ArrayException(unsigned dex_pc, |
| 210 | llvm::Value* array, |
| 211 | llvm::Value* index); |
| 212 | |
| 213 | void EmitGuard_ExceptionLandingPad(unsigned dex_pc); |
| 214 | |
| 215 | private: |
| 216 | //---------------------------------------------------------------------------- |
| 217 | // Garbage Collection Safe Point |
| 218 | //---------------------------------------------------------------------------- |
| 219 | void EmitGuard_GarbageCollectionSuspend(); |
| 220 | |
| 221 | private: |
| 222 | //---------------------------------------------------------------------------- |
| 223 | // Shadow Frame |
| 224 | //---------------------------------------------------------------------------- |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 225 | unsigned num_shadow_frame_entries_; |
| 226 | |
| 227 | void EmitUpdateDexPC(unsigned dex_pc); |
| 228 | |
| 229 | void EmitPopShadowFrame(); |
| 230 | |
| 231 | public: |
| 232 | unsigned AllocShadowFrameEntry(unsigned reg_idx); |
| 233 | |
| 234 | private: |
| 235 | //---------------------------------------------------------------------------- |
| 236 | // Code Generation |
| 237 | //---------------------------------------------------------------------------- |
| 238 | bool CreateFunction(); |
| 239 | llvm::FunctionType* GetFunctionType(); |
| 240 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 241 | bool EmitPrologue(); |
| 242 | bool EmitPrologueAssignArgRegister(); |
| 243 | bool EmitPrologueAllcaShadowFrame(); |
| 244 | bool EmitPrologueLinkBasicBlocks(); |
| 245 | bool PrettyLayoutExceptionBasicBlocks(); |
| 246 | bool VerifyFunction(); |
| 247 | bool OptimizeFunction(); |
| 248 | // Our optimization passes |
| 249 | bool RemoveRedundantPendingExceptionChecks(); |
| 250 | |
| 251 | //---------------------------------------------------------------------------- |
| 252 | // Emit* Helper Functions |
| 253 | //---------------------------------------------------------------------------- |
| 254 | enum CondBranchKind { |
| 255 | kCondBranch_EQ, |
| 256 | kCondBranch_NE, |
| 257 | kCondBranch_LT, |
| 258 | kCondBranch_GE, |
| 259 | kCondBranch_GT, |
| 260 | kCondBranch_LE, |
| 261 | }; |
| 262 | |
| 263 | enum IntArithmKind { |
| 264 | kIntArithm_Add, |
| 265 | kIntArithm_Sub, |
| 266 | kIntArithm_Mul, |
| 267 | kIntArithm_Div, |
| 268 | kIntArithm_Rem, |
| 269 | kIntArithm_And, |
| 270 | kIntArithm_Or, |
| 271 | kIntArithm_Xor, |
| 272 | }; |
| 273 | |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 274 | enum IntShiftArithmKind { |
| 275 | kIntArithm_Shl, |
| 276 | kIntArithm_Shr, |
| 277 | kIntArithm_UShr, |
| 278 | }; |
| 279 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 280 | enum FPArithmKind { |
| 281 | kFPArithm_Add, |
| 282 | kFPArithm_Sub, |
| 283 | kFPArithm_Mul, |
| 284 | kFPArithm_Div, |
| 285 | kFPArithm_Rem, |
| 286 | }; |
| 287 | |
| 288 | enum InvokeArgFmt { |
| 289 | kArgReg, |
| 290 | kArgRange, |
| 291 | }; |
| 292 | |
| 293 | llvm::Value* EmitLoadMethodObjectAddr(); |
| 294 | |
| 295 | llvm::Value* EmitGetCurrentThread(); |
| 296 | |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 297 | void EmitMarkGCCard(llvm::Value* value, llvm::Value* target_addr); |
| 298 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 299 | llvm::Value* EmitInvokeIntrinsicNoThrow(IntrinsicHelper::IntrinsicId intr_id, |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 300 | llvm::ArrayRef<llvm::Value*> args |
| 301 | = llvm::ArrayRef<llvm::Value*>()); |
| 302 | llvm::Value* EmitInvokeIntrinsic2NoThrow(IntrinsicHelper::IntrinsicId intr_id, |
| 303 | llvm::Value* arg1, |
| 304 | llvm::Value* arg2) { |
| 305 | llvm::Value* args[] = { arg1, arg2 }; |
| 306 | return EmitInvokeIntrinsicNoThrow(intr_id, args); |
| 307 | } |
| 308 | llvm::Value* EmitInvokeIntrinsic3NoThrow(IntrinsicHelper::IntrinsicId intr_id, |
| 309 | llvm::Value* arg1, |
| 310 | llvm::Value* arg2, |
| 311 | llvm::Value* arg3) { |
| 312 | llvm::Value* args[] = { arg1, arg2, arg3 }; |
| 313 | return EmitInvokeIntrinsicNoThrow(intr_id, args); |
| 314 | } |
| 315 | llvm::Value* EmitInvokeIntrinsic4NoThrow(IntrinsicHelper::IntrinsicId intr_id, |
| 316 | llvm::Value* arg1, |
| 317 | llvm::Value* arg2, |
| 318 | llvm::Value* arg3, |
| 319 | llvm::Value* arg4) { |
| 320 | llvm::Value* args[] = { arg1, arg2, arg3, arg4 }; |
| 321 | return EmitInvokeIntrinsicNoThrow(intr_id, args); |
| 322 | } |
| 323 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 324 | llvm::Value* EmitInvokeIntrinsic(unsigned dex_pc, |
| 325 | IntrinsicHelper::IntrinsicId intr_id, |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 326 | llvm::ArrayRef<llvm::Value*> args |
| 327 | = llvm::ArrayRef<llvm::Value*>()); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 328 | llvm::Value* EmitInvokeIntrinsic2(unsigned dex_pc, |
| 329 | IntrinsicHelper::IntrinsicId intr_id, |
| 330 | llvm::Value* arg1, |
| 331 | llvm::Value* arg2) { |
| 332 | llvm::Value* args[] = { arg1, arg2 }; |
| 333 | return EmitInvokeIntrinsic(dex_pc, intr_id, args); |
| 334 | } |
| 335 | llvm::Value* EmitInvokeIntrinsic3(unsigned dex_pc, |
| 336 | IntrinsicHelper::IntrinsicId intr_id, |
| 337 | llvm::Value* arg1, |
| 338 | llvm::Value* arg2, |
| 339 | llvm::Value* arg3) { |
| 340 | llvm::Value* args[] = { arg1, arg2, arg3 }; |
| 341 | return EmitInvokeIntrinsic(dex_pc, intr_id, args); |
| 342 | } |
| 343 | llvm::Value* EmitInvokeIntrinsic4(unsigned dex_pc, |
| 344 | IntrinsicHelper::IntrinsicId intr_id, |
| 345 | llvm::Value* arg1, |
| 346 | llvm::Value* arg2, |
| 347 | llvm::Value* arg3, |
| 348 | llvm::Value* arg4) { |
| 349 | llvm::Value* args[] = { arg1, arg2, arg3, arg4 }; |
| 350 | return EmitInvokeIntrinsic(dex_pc, intr_id, args); |
| 351 | } |
| 352 | llvm::Value* EmitInvokeIntrinsic5(unsigned dex_pc, |
| 353 | IntrinsicHelper::IntrinsicId intr_id, |
| 354 | llvm::Value* arg1, |
| 355 | llvm::Value* arg2, |
| 356 | llvm::Value* arg3, |
| 357 | llvm::Value* arg4, |
| 358 | llvm::Value* arg5) { |
| 359 | llvm::Value* args[] = { arg1, arg2, arg3, arg4, arg5 }; |
| 360 | return EmitInvokeIntrinsic(dex_pc, intr_id, args); |
| 361 | } |
| 362 | |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 363 | compiler_llvm::RegCategory GetInferredRegCategory(unsigned dex_pc, |
| 364 | unsigned reg_idx); |
| 365 | |
| 366 | llvm::Value* EmitLoadConstantClass(unsigned dex_pc, uint32_t type_idx); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 367 | |
| 368 | llvm::Value* EmitLoadArrayLength(llvm::Value* array); |
| 369 | |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 370 | llvm::Value* EmitAllocNewArray(unsigned dex_pc, int32_t length, |
| 371 | uint32_t type_idx, bool is_filled_new_array); |
| 372 | |
| 373 | llvm::Value* EmitCompareResultSelection(llvm::Value* cmp_eq, |
| 374 | llvm::Value* cmp_lt); |
| 375 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 376 | llvm::Value* EmitLoadStaticStorage(unsigned dex_pc, unsigned type_idx); |
| 377 | |
| 378 | llvm::Value* EmitConditionResult(llvm::Value* lhs, llvm::Value* rhs, |
| 379 | CondBranchKind cond); |
| 380 | |
| 381 | llvm::Value* EmitIntArithmResultComputation(unsigned dex_pc, |
| 382 | llvm::Value* lhs, |
| 383 | llvm::Value* rhs, |
| 384 | IntArithmKind arithm, |
| 385 | JType op_jty); |
| 386 | |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 387 | llvm::Value* EmitIntShiftArithmResultComputation(uint32_t dex_pc, |
| 388 | llvm::Value* lhs, |
| 389 | llvm::Value* rhs, |
| 390 | IntShiftArithmKind arithm, |
| 391 | JType op_jty); |
| 392 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 393 | llvm::Value* EmitIntDivRemResultComputation(unsigned dex_pc, |
| 394 | llvm::Value* dividend, |
| 395 | llvm::Value* divisor, |
| 396 | IntArithmKind arithm, |
| 397 | JType op_jty); |
| 398 | |
| 399 | #define GEN_INSN_ARGS unsigned dex_pc, const Instruction* insn |
| 400 | // NOP, PAYLOAD (unreachable) instructions |
| 401 | void EmitInsn_Nop(GEN_INSN_ARGS); |
| 402 | |
| 403 | // MOVE, MOVE_RESULT instructions |
| 404 | void EmitInsn_Move(GEN_INSN_ARGS, JType jty); |
| 405 | void EmitInsn_MoveResult(GEN_INSN_ARGS, JType jty); |
| 406 | |
| 407 | // MOVE_EXCEPTION, THROW instructions |
| 408 | void EmitInsn_MoveException(GEN_INSN_ARGS); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 409 | void EmitInsn_ThrowException(GEN_INSN_ARGS); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 410 | |
| 411 | // RETURN instructions |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 412 | void EmitInsn_ReturnVoid(GEN_INSN_ARGS); |
| 413 | void EmitInsn_Return(GEN_INSN_ARGS); |
| 414 | |
| 415 | // CONST, CONST_CLASS, CONST_STRING instructions |
| 416 | void EmitInsn_LoadConstant(GEN_INSN_ARGS, JType imm_jty); |
| 417 | void EmitInsn_LoadConstantString(GEN_INSN_ARGS); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 418 | void EmitInsn_LoadConstantClass(GEN_INSN_ARGS); |
| 419 | |
| 420 | // MONITOR_ENTER, MONITOR_EXIT instructions |
| 421 | void EmitInsn_MonitorEnter(GEN_INSN_ARGS); |
| 422 | void EmitInsn_MonitorExit(GEN_INSN_ARGS); |
| 423 | |
| 424 | // CHECK_CAST, INSTANCE_OF instructions |
| 425 | void EmitInsn_CheckCast(GEN_INSN_ARGS); |
| 426 | void EmitInsn_InstanceOf(GEN_INSN_ARGS); |
| 427 | |
| 428 | // NEW_INSTANCE instructions |
| 429 | void EmitInsn_NewInstance(GEN_INSN_ARGS); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 430 | |
| 431 | // ARRAY_LEN, NEW_ARRAY, FILLED_NEW_ARRAY, FILL_ARRAY_DATA instructions |
| 432 | void EmitInsn_ArrayLength(GEN_INSN_ARGS); |
| 433 | void EmitInsn_NewArray(GEN_INSN_ARGS); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 434 | void EmitInsn_FilledNewArray(GEN_INSN_ARGS, bool is_range); |
| 435 | void EmitInsn_FillArrayData(GEN_INSN_ARGS); |
| 436 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 437 | // GOTO, IF_TEST, IF_TESTZ instructions |
| 438 | void EmitInsn_UnconditionalBranch(GEN_INSN_ARGS); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 439 | void EmitInsn_UnaryConditionalBranch(GEN_INSN_ARGS, CondBranchKind cond); |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 440 | void EmitInsn_BinaryConditionalBranch(GEN_INSN_ARGS, CondBranchKind cond); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 441 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 442 | // PACKED_SWITCH, SPARSE_SWITCH instrutions |
| 443 | void EmitInsn_PackedSwitch(GEN_INSN_ARGS); |
| 444 | void EmitInsn_SparseSwitch(GEN_INSN_ARGS); |
| 445 | |
| 446 | // CMPX_FLOAT, CMPX_DOUBLE, CMP_LONG instructions |
| 447 | void EmitInsn_FPCompare(GEN_INSN_ARGS, JType fp_jty, bool gt_bias); |
| 448 | void EmitInsn_LongCompare(GEN_INSN_ARGS); |
| 449 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 450 | // AGET, APUT instrutions |
| 451 | void EmitInsn_AGet(GEN_INSN_ARGS, JType elem_jty); |
| 452 | void EmitInsn_APut(GEN_INSN_ARGS, JType elem_jty); |
| 453 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 454 | // IGET, IPUT instructions |
| 455 | void EmitInsn_IGet(GEN_INSN_ARGS, JType field_jty); |
| 456 | void EmitInsn_IPut(GEN_INSN_ARGS, JType field_jty); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 457 | |
| 458 | // SGET, SPUT instructions |
| 459 | void EmitInsn_SGet(GEN_INSN_ARGS, JType field_jty); |
| 460 | void EmitInsn_SPut(GEN_INSN_ARGS, JType field_jty); |
| 461 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 462 | void EmitInsn_Invoke(GEN_INSN_ARGS, |
| 463 | InvokeType invoke_type, |
| 464 | InvokeArgFmt arg_fmt); |
| 465 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 466 | // Unary instructions |
| 467 | void EmitInsn_Neg(GEN_INSN_ARGS, JType op_jty); |
| 468 | void EmitInsn_Not(GEN_INSN_ARGS, JType op_jty); |
| 469 | void EmitInsn_SExt(GEN_INSN_ARGS); |
| 470 | void EmitInsn_Trunc(GEN_INSN_ARGS); |
| 471 | void EmitInsn_TruncAndSExt(GEN_INSN_ARGS, unsigned N); |
| 472 | void EmitInsn_TruncAndZExt(GEN_INSN_ARGS, unsigned N); |
| 473 | |
| 474 | void EmitInsn_FNeg(GEN_INSN_ARGS, JType op_jty); |
| 475 | void EmitInsn_IntToFP(GEN_INSN_ARGS, JType src_jty, JType dest_jty); |
| 476 | void EmitInsn_FPToInt(GEN_INSN_ARGS, JType src_jty, JType dest_jty, |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 477 | IntrinsicHelper::IntrinsicId intr_id); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 478 | void EmitInsn_FExt(GEN_INSN_ARGS); |
| 479 | void EmitInsn_FTrunc(GEN_INSN_ARGS); |
| 480 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 481 | // Integer binary arithmetic instructions |
| 482 | void EmitInsn_IntArithm(GEN_INSN_ARGS, IntArithmKind arithm, |
| 483 | JType op_jty, bool is_2addr); |
| 484 | |
| 485 | void EmitInsn_IntArithmImmediate(GEN_INSN_ARGS, IntArithmKind arithm); |
| 486 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 487 | void EmitInsn_IntShiftArithm(GEN_INSN_ARGS, IntShiftArithmKind arithm, |
| 488 | JType op_jty, bool is_2addr); |
| 489 | |
| 490 | void EmitInsn_IntShiftArithmImmediate(GEN_INSN_ARGS, |
| 491 | IntShiftArithmKind arithm); |
| 492 | |
| 493 | void EmitInsn_RSubImmediate(GEN_INSN_ARGS); |
| 494 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 495 | // Floating-point binary arithmetic instructions |
| 496 | void EmitInsn_FPArithm(GEN_INSN_ARGS, FPArithmKind arithm, |
| 497 | JType op_jty, bool is_2addr); |
| 498 | #undef GEN_INSN_ARGS |
| 499 | |
| 500 | |
| 501 | bool EmitInstructions(); |
| 502 | bool EmitInstruction(unsigned dex_pc, const Instruction* insn); |
| 503 | |
| 504 | DISALLOW_COPY_AND_ASSIGN(DexLang); |
| 505 | }; |
| 506 | |
| 507 | } // namespace greenland |
| 508 | } // namespace art |
| 509 | |
| 510 | #endif // ART_SRC_GREENLAND_DEX_LANG_H_ |