nany
instruction.h
1 #pragma once
2 #include "libnanyc.h"
3 #include "details/ir/isa/opcodes.h"
4 #include "details/ir/isa/data.h"
5 
6 
7 
8 namespace ny {
9 namespace ir {
10 
11 
12 struct Instruction final {
13  uint32_t opcodes[4];
14 
16  template<isa::Op O> isa::Operand<O>& to() {
17  return reinterpret_cast<isa::Operand<O>&>(*this);
18  }
19 
21  template<isa::Op O> const isa::Operand<O>& to() const {
22  return reinterpret_cast<const isa::Operand<O>&>(*this);
23  }
24 
25  template<isa::Op O>
26  static Instruction& fromOpcode(isa::Operand<O>& opc) {
27  return reinterpret_cast<Instruction&>(opc);
28  }
29 
30  template<isa::Op O>
31  static const Instruction& fromOpcode(const isa::Operand<O>& opc) {
32  return reinterpret_cast<const Instruction&>(opc);
33  }
34 
35 }; // struct Instruction
36 
37 
38 
39 
40 
41 } // namespace ir
42 } // namespace ny
Definition: ast.cpp:6
isa::Operand< O > & to()
Convert the instruction into an Opcode struct.
Definition: instruction.h:16
Definition: instruction.h:12
const isa::Operand< O > & to() const
Convert the instruction into an Opcode struct (const)
Definition: instruction.h:21
Definition: data.h:85