diff options
Diffstat (limited to 'compiler/optimizing/code_generator.h')
-rw-r--r-- | compiler/optimizing/code_generator.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h index 0310877f18..f46a36d02f 100644 --- a/compiler/optimizing/code_generator.h +++ b/compiler/optimizing/code_generator.h @@ -245,6 +245,32 @@ class CodeGenerator { return GetFrameSize() == (CallPushesPC() ? GetWordSize() : 0); } + static int32_t GetInt32ValueOf(HConstant* constant) { + if (constant->IsIntConstant()) { + return constant->AsIntConstant()->GetValue(); + } else if (constant->IsNullConstant()) { + return 0; + } else { + DCHECK(constant->IsFloatConstant()); + return bit_cast<float, int32_t>(constant->AsFloatConstant()->GetValue()); + } + } + + static int64_t GetInt64ValueOf(HConstant* constant) { + if (constant->IsIntConstant()) { + return constant->AsIntConstant()->GetValue(); + } else if (constant->IsNullConstant()) { + return 0; + } else if (constant->IsFloatConstant()) { + return bit_cast<float, int32_t>(constant->AsFloatConstant()->GetValue()); + } else if (constant->IsLongConstant()) { + return constant->AsLongConstant()->GetValue(); + } else { + DCHECK(constant->IsDoubleConstant()); + return bit_cast<double, int64_t>(constant->AsDoubleConstant()->GetValue()); + } + } + protected: CodeGenerator(HGraph* graph, size_t number_of_core_registers, |