Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1167)

Unified Diff: src/compiler/code-generator-impl.h

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/code-generator.cc ('k') | src/compiler/common-node-cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/code-generator-impl.h
diff --git a/src/compiler/code-generator-impl.h b/src/compiler/code-generator-impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..b5b5451b7bab5fe4262be6d3e819b623a73883fa
--- /dev/null
+++ b/src/compiler/code-generator-impl.h
@@ -0,0 +1,130 @@
+// Copyright 2013 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_COMPILER_CODE_GENERATOR_IMPL_H_
+#define V8_COMPILER_CODE_GENERATOR_IMPL_H_
+
+#include "src/compiler/code-generator.h"
+#include "src/compiler/common-operator.h"
+#include "src/compiler/generic-graph.h"
+#include "src/compiler/instruction.h"
+#include "src/compiler/linkage.h"
+#include "src/compiler/machine-operator.h"
+#include "src/compiler/node.h"
+#include "src/compiler/opcodes.h"
+#include "src/compiler/operator.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+// Converts InstructionOperands from a given instruction to
+// architecture-specific
+// registers and operands after they have been assigned by the register
+// allocator.
+class InstructionOperandConverter {
+ public:
+ InstructionOperandConverter(CodeGenerator* gen, Instruction* instr)
+ : gen_(gen), instr_(instr) {}
+
+ Register InputRegister(int index) {
+ return ToRegister(instr_->InputAt(index));
+ }
+
+ DoubleRegister InputDoubleRegister(int index) {
+ return ToDoubleRegister(instr_->InputAt(index));
+ }
+
+ double InputDouble(int index) { return ToDouble(instr_->InputAt(index)); }
+
+ int32_t InputInt32(int index) {
+ return ToConstant(instr_->InputAt(index)).ToInt32();
+ }
+
+ int8_t InputInt8(int index) { return static_cast<int8_t>(InputInt32(index)); }
+
+ int16_t InputInt16(int index) {
+ return static_cast<int16_t>(InputInt32(index));
+ }
+
+ uint8_t InputInt5(int index) {
+ return static_cast<uint8_t>(InputInt32(index) & 0x1F);
+ }
+
+ uint8_t InputInt6(int index) {
+ return static_cast<uint8_t>(InputInt32(index) & 0x3F);
+ }
+
+ Handle<HeapObject> InputHeapObject(int index) {
+ return ToHeapObject(instr_->InputAt(index));
+ }
+
+ Label* InputLabel(int index) {
+ return gen_->code()->GetLabel(InputBlock(index));
+ }
+
+ BasicBlock* InputBlock(int index) {
+ NodeId block_id = static_cast<NodeId>(instr_->InputAt(index)->index());
+ // operand should be a block id.
+ ASSERT(block_id >= 0);
+ ASSERT(block_id < gen_->schedule()->BasicBlockCount());
+ return gen_->schedule()->GetBlockById(block_id);
+ }
+
+ Register OutputRegister() { return ToRegister(instr_->Output()); }
+
+ DoubleRegister OutputDoubleRegister() {
+ return ToDoubleRegister(instr_->Output());
+ }
+
+ Register TempRegister(int index) { return ToRegister(instr_->TempAt(index)); }
+
+ Register ToRegister(InstructionOperand* op) {
+ ASSERT(op->IsRegister());
+ return Register::FromAllocationIndex(op->index());
+ }
+
+ DoubleRegister ToDoubleRegister(InstructionOperand* op) {
+ ASSERT(op->IsDoubleRegister());
+ return DoubleRegister::FromAllocationIndex(op->index());
+ }
+
+ Constant ToConstant(InstructionOperand* operand) {
+ if (operand->IsImmediate()) {
+ return gen_->code()->GetImmediate(operand->index());
+ }
+ return gen_->code()->GetConstant(operand->index());
+ }
+
+ double ToDouble(InstructionOperand* operand) {
+ return ToConstant(operand).ToFloat64();
+ }
+
+ Handle<HeapObject> ToHeapObject(InstructionOperand* operand) {
+ return ToConstant(operand).ToHeapObject();
+ }
+
+ Frame* frame() const { return gen_->frame(); }
+ Isolate* isolate() const { return gen_->isolate(); }
+ Linkage* linkage() const { return gen_->linkage(); }
+
+ protected:
+ CodeGenerator* gen_;
+ Instruction* instr_;
+};
+
+
+// TODO(dcarney): generify this on bleeding_edge and replace this call
+// when merged.
+static inline void FinishCode(MacroAssembler* masm) {
+#if V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_ARM
+ masm->CheckConstPool(true, false);
+#endif
+}
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
+
+#endif // V8_COMPILER_CODE_GENERATOR_IMPL_H
« no previous file with comments | « src/compiler/code-generator.cc ('k') | src/compiler/common-node-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698