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)_insids.h -----------------------------------*- C++ -*-===//
18 // Instruction IDs for X86, %(N)-bit
20 // Copyright (C) 2013-2014 Dirk Steinke.
21 // See copyright and license notice in COPYRIGHT or include/jitcs.h
23 // Instructions are grouped as Instruction classes. This header adds some
24 // convenience functions for handling the instruction and class IDs.
25 //===----------------------------------------------------------------------===//
27 #ifndef _JITCS_X86_%(N)_INSIDS_H_
28 #define _JITCS_X86_%(N)_INSIDS_H_
30 #include "jitcs_base.h"
31 #include "jitcs_ids.h"
32 #include "jitcs_x86_common_insids.h"
34 /*| local data= runfile("../src/data/x86_inslist.dat")
40 using x86_common::CondCodeId;
43 ICL_SubMask = (1 << ICL_SubBits) - 1,
45 ICL_NonMainBits = ICL_SubBits + ICL_AuxBits,
46 ICL_NonMainMask = (1 << ICL_NonMainBits) - 1,
49 ICL_First = (I_CoreMax + ICL_NonMainMask) >> ICL_NonMainBits,
50 /*| local function ps(n,s) return n .. (#n < s and string.rep(" ",s-#n) or "") end
51 /*| local first = true
52 /*| for k,cl in pred_ipairs(data.opclasses, function(k,cl) return isa(cl.isa) end) do
53 ICL_%(cl.id)%(first and " = ICL_First" or ""), // ? members
59 enum { ICL_Count = ICL_Last - ICL_First };
61 template <InsId ID> struct ToInsClassCT {
62 static const InsClassId Value = static_cast<InsClassId>(ID >> ICL_NonMainBits);
64 inline InsClassId ToInsClass(InsId id) { return static_cast<InsClassId>(id >> ICL_NonMainBits); }
65 template <InsClassId ICL> struct IsValidInsClassCT {
66 static const bool Value = (ICL >= ICL_First && ICL < ICL_Last);
68 inline bool IsValid(InsClassId icl) { return icl >= ICL_First && icl < ICL_Last; }
71 inline T ReadFromInsClassArray(T arr[ICL_Count] , InsClassId icl) {
73 return arr[icl - x86_%(N)::ICL_First];
76 #define INSID(CID,SUB,AUX) static_cast<InsId>(((CID) << ICL_NonMainBits) + ((AUX) << ICL_SubBits) + (SUB))
77 /*| for k,op in pred_ipairs(data.ops, function(k,op) return isa(op.opclass.isa) end) do
78 static const InsId I_%(ps(op.name, 20)) = INSID(ICL_%(op.opclass.id), %(op.sub or 0), %(op.sub2 or 0));
83 /*| local al= runfile("../src/data/x86_insalias.dat")
85 /*| for k,v in ipairs{{0,al.aliases}, {N,al["aliases"..N]}} do
86 /*| for kk,vv in ipairs(v[2]) do
87 static const InsId I_%(ps(vv[1],20)) = I_%(vv[2]);
91 } // end of namespace jitcs::x86_%(N)
92 } // end of namespace jitcs
94 // _JITCS_X86_%(N)_INSIDS_H_