diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-09-07 10:31:37 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-09-07 10:31:37 -0700 |
| commit | 0e566a63f0bafb7def65521315e9f19a2bc79e34 (patch) | |
| tree | 470c20f7948693f39b7603645ad9d09fb693c459 /source/slang/ir.h | |
| parent | ca16ede67d3fc34ec1cc81b8f835199c5ef1ab9a (diff) | |
| parent | ced92a047e510480cff15be1a1cd102abffa3f82 (diff) | |
Merge pull request #177 from tfoleyNV/ir-work
Replace old notion of "intrinsic" operations
Diffstat (limited to 'source/slang/ir.h')
| -rw-r--r-- | source/slang/ir.h | 80 |
1 files changed, 74 insertions, 6 deletions
diff --git a/source/slang/ir.h b/source/slang/ir.h index aa7b6a045..51755f89f 100644 --- a/source/slang/ir.h +++ b/source/slang/ir.h @@ -7,13 +7,36 @@ // similar in spirit to LLVM (but much simpler). // -#include "type-layout.h" +#include "../core/basic.h" -// We need the definition of `BaseType` which currently belongs to the AST -#include "syntax.h" namespace Slang { +// TODO(tfoley): We should ditch this enumeration +// and just use the IR opcodes that represent these +// types directly. The one major complication there +// is that the order of the enum values currently +// matters, since it determines promotion rank. +// We either need to keep that restriction, or +// look up promotion rank by some other means. +// +enum class BaseType +{ + // Note(tfoley): These are ordered in terms of promotion rank, so be vareful when messing with this + + Void = 0, + Bool, + Int, + UInt, + UInt64, + Half, + Float, + Double, +}; + + +class Layout; + struct IRFunc; struct IRInst; struct IRModule; @@ -29,14 +52,59 @@ enum : IROpFlags kIROpFlag_Parent = 1 << 0, }; -enum IROp : uint16_t +enum IROp : int16_t { - #define INST(ID, MNEMONIC, ARG_COUNT, FLAGS) \ kIROp_##ID, #include "ir-inst-defs.h" + + kIROpCount, + + // We use the negative range of opcode values + // to encode "pseudo" instructions that should + // not appear in valid IR. + + kIRPseduoOp_FirstPseudo = -1000, + +#define INST(ID, MNEMONIC, ARG_COUNT, FLAGS) /* empty */ +#define PSEUDO_INST(ID) kIRPseudoOp_##ID, + +#include "ir-inst-defs.h" + + kIROp_Invalid = -1, + +}; + +#if 0 +enum IRPseudoOp +{ + kIRPseudoOp_Pos = -1000, + kIRPseudoOp_PreInc, + kIRPseudoOp_PreDec, + kIRPseudoOp_PostInc, + kIRPseudoOp_PostDec, + kIRPseudoOp_Sequence, + kIRPseudoOp_AddAssign, + kIRPseudoOp_SubAssign, + kIRPseudoOp_MulAssign, + kIRPseudoOp_DivAssign, + kIRPseudoOp_ModAssign, + kIRPseudoOp_AndAssign, + kIRPseudoOp_OrAssign, + kIRPseudoOp_XorAssign , + kIRPseudoOp_LshAssign, + kIRPseudoOp_RshAssign, + kIRPseudoOp_Assign, + kIRPseudoOp_BitNot, + kIRPseudoOp_And, + kIRPseudoOp_Or, + + kIROp_Invalid = -1, }; +#endif + +IROp findIROp(char const* name); // A logical operation/opcode in the IR struct IROpInfo @@ -448,7 +516,7 @@ struct IRBuilder IRInst* emitIntrinsicInst( IRType* type, - IntrinsicOp intrinsicOp, + IROp op, UInt argCount, IRValue* const* args); |
