Permalink
Browse files

fullgen: dark knight returns

  • Loading branch information...
1 parent 404fccf commit 87b964554495d35db4f9be4aeb4e09b025c420e2 @indutny committed Nov 12, 2012
Showing with 245 additions and 165 deletions.
  1. +4 −0 candor.gyp
  2. +15 −0 src/fullgen-inl.h
  3. +37 −0 src/fullgen-instructions-inl.h
  4. +28 −0 src/fullgen-instructions.cc
  5. +49 −0 src/fullgen-instructions.h
  6. +41 −0 src/fullgen.cc
  7. +53 −165 src/fullgen.h
  8. +9 −0 src/ia32/fullgen-ia32.cc
  9. +9 −0 src/x64/fullgen-x64.cc
View
@@ -29,6 +29,8 @@
'src/root.cc',
'src/visitor.cc',
'src/source-map.cc',
+ 'src/fullgen.cc',
+ 'src/fullgen-instructions.cc',
'src/hir.cc',
'src/hir-instructions.cc',
'src/lir.cc',
@@ -43,6 +45,7 @@
'src/x64/assembler-x64.cc',
'src/x64/macroassembler-x64.cc',
'src/x64/stubs-x64.cc',
+ 'src/x64/fullgen-x64.cc',
'src/x64/lir-builder-x64.cc',
'src/x64/lir-x64.cc',
'src/x64/pic-x64.cc',
@@ -53,6 +56,7 @@
'src/ia32/assembler-ia32.cc',
'src/ia32/macroassembler-ia32.cc',
'src/ia32/stubs-ia32.cc',
+ 'src/ia32/fullgen-ia32.cc',
'src/ia32/lir-builder-ia32.cc',
'src/ia32/lir-ia32.cc',
'src/ia32/pic-ia32.cc',
View
@@ -0,0 +1,15 @@
+#ifndef _SRC_FULLGEN_INL_H_
+#define _SRC_FULLGEN_INL_H_
+
+namespace candor {
+namespace internal {
+
+inline void Fullgen::Print(char* out, int32_t size) {
+ PrintBuffer p(out, size);
+ Print(&p);
+}
+
+} // namespace internal
+} // namespace candor
+
+#endif // _SRC_FULLGEN_INL_H_
@@ -0,0 +1,37 @@
+#ifndef _SRC_FULLGEN_INSTRUCTION_INL_H_
+#define _SRC_FULLGEN_INSTRUCTION_INL_H_
+
+#include "fullgen-instructions.h"
+#include <assert.h> // assert
+
+namespace candor {
+namespace internal {
+
+inline void FInstruction::SetResult(FOperand* op) {
+ assert(result == NULL);
+ result = op;
+}
+
+
+inline void FInstruction::AddArg(FOperand* op) {
+ assert(input_count_ < 3);
+ inputs[input_count_++];
+}
+
+#define FULLGEN_INSTRUCTION_TYPE_TO_STR(V) \
+ case k##V: return #V;
+
+inline const char* FInstruction::TypeToStr(Type type) {
+ switch (type) {
+ FULLGEN_INSTRUCTION_TYPES(FULLGEN_INSTRUCTION_TYPE_TO_STR)
+ default: UNEXPECTED break;
+ }
+ return "none";
+}
+
+#undef FULLGEN_INSTRUCTION_TYPE_TO_STR
+
+} // namespace internal
+} // namespace candor
+
+#endif // _SRC_FULLGEN_INSTRUCTION_INL_H_
@@ -0,0 +1,28 @@
+#include "fullgen.h"
+#include "fullgen-instructions.h"
+#include "fullgen-instructions-inl.h"
+
+namespace candor {
+namespace internal {
+
+FInstruction::FInstruction(Type type) : id(-1), type_(type), input_count_(0) {
+ result = NULL;
+ inputs[0] = NULL;
+ inputs[1] = NULL;
+ inputs[2] = NULL;
+}
+
+
+void FInstruction::Print(PrintBuffer* p) {
+ p->Print("%d ", id);
+ if (result != NULL) result->Print(p);
+ p->Print("= %s(", id, TypeToStr(type_));
+ for (int i = 0; i < input_count_; i++) {
+ inputs[i]->Print(p);
+ if (i + 1 < input_count_) p->Print(", ");
+ }
+ p->Print(")\n");
+}
+
+} // internal
+} // candor
View
@@ -0,0 +1,49 @@
+#ifndef _SRC_FULLGEN_INSTRUCTIONS_H
+#define _SRC_FULLGEN_INSTRUCTIONS_H
+
+#include "zone.h"
+#include "utils.h"
+
+namespace candor {
+namespace internal {
+
+// Forward declarations
+class Masm;
+
+#define FULLGEN_INSTRUCTION_TYPES(V) \
+ V(Nop)
+
+#define FULLGEN_INSTRUCTION_ENUM(V) \
+ k##V,
+
+class FInstruction : public ZoneObject {
+ public:
+ enum Type {
+ FULLGEN_INSTRUCTION_TYPES(FULLGEN_INSTRUCTION_ENUM)
+ kNone
+ };
+
+ FInstruction(Type type);
+
+ static inline const char* TypeToStr(Type type);
+ inline void SetResult(FOperand* op);
+ inline void AddArg(FOperand* op);
+
+ virtual void Print(PrintBuffer* p);
+ virtual void Generate(Masm* masm) = 0;
+
+ int id;
+ FOperand* result;
+ FOperand* inputs[3];
+
+ protected:
+ Type type_;
+ int input_count_;
+};
+
+#undef FULLGEN_INSTRUCTION_ENUM
+
+} // internal
+} // candor
+
+#endif // _SRC_FULLGEN_INSTRUCTIONS_H
View
@@ -0,0 +1,41 @@
+#include "fullgen.h"
+#include "fullgen-inl.h"
+#include "code-space.h"
+#include "heap.h"
+#include "heap-inl.h"
+#include "macroassembler.h"
+
+namespace candor {
+namespace internal {
+
+Fullgen::Fullgen(CodeSpace* space, SourceMap* map)
+ : Visitor<FInstruction>(kPreorder),
+ space_(space),
+ root_(space->heap()),
+ loop_start_(NULL),
+ loop_end_(NULL),
+ source_map_(map) {
+}
+
+
+void Fullgen::Generate(AstNode* ast) {
+}
+
+
+void Fullgen::Print(PrintBuffer* p) {
+ p->Print("## Fullgen\n");
+ p->Print("## Fullgen ends\n");
+}
+
+
+void FOperand::Print(PrintBuffer* p) {
+ switch (type_) {
+ case kStack: p->Print("s[%d]", index_); break;
+ case kContext: p->Print("c[%d:%d]", index_, depth_); break;
+ case kRegister: p->Print("%s", RegisterNameByIndex(index_)); break;
+ default: UNEXPECTED
+ }
+}
+
+} // namespace internal
+} // namespace candor
Oops, something went wrong.

0 comments on commit 87b9645

Please sign in to comment.