1 #/bin/emblua LUAPREFIX=/*|
6 /*| function pred_ipairs(t, pred)
7 /*| return function(t,k)
12 /*| until not v or pred(k, v)
16 /*| function isa(v) return not v[N==32 and "x64" or "x32only"] end
17 //===-- jitcs_x86_%(N)_regs.h C++ -----------------------------------------*-===//
19 // Instruction and instruction class ids (+ condition codes) for %(N)bit x86 code.
21 //===----------------------------------------------------------------------===//
23 #ifndef _JITCS_X86_%(N)_INSIDS_H_
24 #define _JITCS_X86_%(N)_INSIDS_H_
26 #include "jitcs_base.h"
27 #include "jitcs_ids.h"
28 #include "jitcs_x86_common_insids.h"
30 /*| local data= runfile("../src/data/x86_inslist.dat")
36 using x86_common::CondCodeId;
39 ICL_SubMask = (1 << ICL_SubBits) - 1,
41 ICL_NonMainBits = ICL_SubBits + ICL_AuxBits,
42 ICL_NonMainMask = (1 << ICL_NonMainBits) - 1,
45 ICL_First = (I_CoreMax + ICL_NonMainMask) >> ICL_NonMainBits,
46 /*| local function ps(n,s) return n .. (#n < s and string.rep(" ",s-#n) or "") end
47 /*| local first = true
48 /*| for k,cl in pred_ipairs(data.opclasses, function(k,cl) return isa(cl.isa) end) do
49 ICL_%(cl.id)%(first and " = ICL_First" or ""), // ? members
55 enum { ICL_Count = ICL_Last - ICL_First };
57 template <InsId ID> struct ToInsClassCT {
58 static const InsClassId Value = static_cast<InsClassId>(ID >> ICL_NonMainBits);
60 inline InsClassId ToInsClass(InsId id) { return static_cast<InsClassId>(id >> ICL_NonMainBits); }
61 template <InsClassId ICL> struct IsValidInsClassCT {
62 static const bool Value = (ICL >= ICL_First && ICL < ICL_Last);
64 inline bool IsValid(InsClassId icl) { return icl >= ICL_First && icl < ICL_Last; }
67 inline T ReadFromInsClassArray(T arr[ICL_Count] , InsClassId icl) {
69 return arr[icl - x86_%(N)::ICL_First];
72 #define INSID(CID,SUB,AUX) static_cast<InsId>(((CID) << ICL_NonMainBits) + ((AUX) << ICL_SubBits) + (SUB))
73 /*| for k,op in pred_ipairs(data.ops, function(k,op) return isa(op.opclass.isa) end) do
74 static const InsId I_%(ps(op.name, 20)) = INSID(ICL_%(op.opclass.id), %(op.sub or 0), %(op.sub2 or 0));
79 /*| local al= runfile("../src/data/x86_insalias.dat")
81 /*| for k,v in ipairs{{0,al.aliases}, {N,al["aliases"..N]}} do
82 /*| for kk,vv in ipairs(v[2]) do
83 static const InsId I_%(ps(vv[1],20)) = I_%(vv[2]);
87 } // end of namespace jitcs::x86_%(N)
88 } // end of namespace jitcs
90 // _JITCS_X86_%(N)_INSIDS_H_