From 3e4f93a6a971ea8c70c6b3d505c3ee6226125afb Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Mon, 30 Dec 2013 00:11:36 -0800 Subject: [PATCH] Playing with sequences. --- .../x64/lowering/lowering_sequences.cc | 157 +++++++++++++++++- 1 file changed, 150 insertions(+), 7 deletions(-) diff --git a/src/alloy/backend/x64/lowering/lowering_sequences.cc b/src/alloy/backend/x64/lowering/lowering_sequences.cc index 7d55a4f6c..f9caadca7 100644 --- a/src/alloy/backend/x64/lowering/lowering_sequences.cc +++ b/src/alloy/backend/x64/lowering/lowering_sequences.cc @@ -29,6 +29,8 @@ enum ArgType { NULL_ARG_TYPE, VALUE_ARG_TYPE, CONSTANT_ARG_TYPE, + SYMBOL_ARG_TYPE, + LABEL_ARG_TYPE, OUT_ARG_TYPE, IN_ARG_TYPE, REG_ARG_TYPE, @@ -44,7 +46,13 @@ class NullArg : public Arg {}; template class ValueRef : public Arg { public: - enum { type = TYPE }; + const static int type = TYPE; +}; +class SymbolRef : public Arg { +public: +}; +class LabelRef : public Arg { +public: }; template { public: - enum { type = TYPE }; - enum : bool { has_value = HAS_VALUE }; + const static int type = TYPE; + const static bool has_value = HAS_VALUE; const static int8_t i8 = INT8_VALUE; const static int16_t i16 = INT16_VALUE; const static int32_t i32 = INT32_VALUE; @@ -87,20 +95,20 @@ class Float64Constant : public Constant class Out : public Arg { public: - enum { slot = SLOT }; + const static int slot = SLOT; }; template class In : public Arg { public: - enum { slot = SLOT }; - enum { arg = ARG }; + const static int slot = SLOT; + const static int arg = ARG; }; template class Reg : public Arg { public: - enum { reg_name = REG_NAME }; + const static int reg_name = REG_NAME; }; @@ -117,6 +125,14 @@ public: return op.value->type == T::type; } template + static bool CheckArg(Instr* instr_list[], Instr::Op& op, IntType) { + return true; + } + template + static bool CheckArg(Instr* instr_list[], Instr::Op& op, IntType) { + return true; + } + template static bool CheckArg(Instr* instr_list[], Instr::Op& op, IntType) { if (op.value->type != T::type) { return false; @@ -397,11 +413,138 @@ public: void alloy::backend::x64::lowering::RegisterSequences(LoweringTable* table) { + // TODO(benvanik): translate comments somehow - special type? + Translate + >, tuple< + >> (table); + Translate >, tuple< >> (table); + // -------------------------------------------------------------------------- + // Debugging + // -------------------------------------------------------------------------- + + // TODO(benvanik): translate source offsets for mapping + Translate> + >, tuple< + >> (table); + + Translate + >, tuple< + // int3 + >> (table); + Translate> + >, tuple< + // test if 0 + // jz label + // int3 + // label: + >> (table); + + Translate + >, tuple< + // int3 + >> (table); + Translate> + >, tuple< + // test if 0 + // jz label + // int3 + // label: + >> (table); + + // -------------------------------------------------------------------------- + // Calls + // -------------------------------------------------------------------------- + + Translate + >, tuple< + // call + >> (table); + Translate, SymbolRef> + >, tuple< + // call + >> (table); + Translate> + >, tuple< + // call + >> (table); + Translate, ValueRef> + >, tuple< + // call + >> (table); + // return / set return address + + // -------------------------------------------------------------------------- + // Branches + // -------------------------------------------------------------------------- + + Translate + >, tuple< + // branch + >> (table); + Translate, LabelRef> + >, tuple< + // branch + >> (table); + Translate, LabelRef> + >, tuple< + // branch + >> (table); + + // -------------------------------------------------------------------------- + // Types + // -------------------------------------------------------------------------- + + // int 8/etc + Translate, ValueRef> + >, tuple< + LIR_MOV_I32, In<0, 0>> + >> (table); + + // -------------------------------------------------------------------------- + // Constants + // -------------------------------------------------------------------------- + + // -------------------------------------------------------------------------- + // Context + // -------------------------------------------------------------------------- + + // -------------------------------------------------------------------------- + // Memory + // -------------------------------------------------------------------------- + + // -------------------------------------------------------------------------- + // Comparisons + // -------------------------------------------------------------------------- + + // -------------------------------------------------------------------------- + // Math + // -------------------------------------------------------------------------- + + // -------------------------------------------------------------------------- + // Atomic + // -------------------------------------------------------------------------- + + // Tests: + Translate, ValueRef, ValueRef> >, tuple<