OLD | NEW |
1 //===- subzero/src/IceInst.h - High-level instructions ----------*- C++ -*-===// | 1 //===- subzero/src/IceInst.h - High-level instructions ----------*- C++ -*-===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
11 /// \brief Declares the Inst class and its target-independent subclasses. | 11 /// \brief Declares the Inst class and its target-independent subclasses. |
12 /// | 12 /// |
13 /// These represent the high-level Vanilla ICE instructions and map roughly 1:1 | 13 /// These represent the high-level Vanilla ICE instructions and map roughly 1:1 |
14 /// to LLVM instructions. | 14 /// to LLVM instructions. |
15 /// | 15 /// |
16 //===----------------------------------------------------------------------===// | 16 //===----------------------------------------------------------------------===// |
17 | 17 |
18 #ifndef SUBZERO_SRC_ICEINST_H | 18 #ifndef SUBZERO_SRC_ICEINST_H |
19 #define SUBZERO_SRC_ICEINST_H | 19 #define SUBZERO_SRC_ICEINST_H |
20 | 20 |
21 #include "IceCfg.h" | 21 #include "IceCfg.h" |
22 #include "IceDefs.h" | 22 #include "IceDefs.h" |
23 #include "IceInst.def" | 23 #include "IceInst.def" |
24 #include "IceIntrinsics.h" | 24 #include "IceIntrinsics.h" |
| 25 #include "IceOperand.h" |
25 #include "IceSwitchLowering.h" | 26 #include "IceSwitchLowering.h" |
26 #include "IceTypes.h" | 27 #include "IceTypes.h" |
27 | 28 |
28 // TODO: The Cfg structure, and instructions in particular, need to be | 29 // TODO: The Cfg structure, and instructions in particular, need to be |
29 // validated for things like valid operand types, valid branch targets, proper | 30 // validated for things like valid operand types, valid branch targets, proper |
30 // ordering of Phi and non-Phi instructions, etc. Most of the validity checking | 31 // ordering of Phi and non-Phi instructions, etc. Most of the validity checking |
31 // will be done in the bitcode reader. We need a list of everything that should | 32 // will be done in the bitcode reader. We need a list of everything that should |
32 // be validated, and tests for each. | 33 // be validated, and tests for each. |
33 | 34 |
34 namespace Ice { | 35 namespace Ice { |
(...skipping 19 matching lines...) Expand all Loading... |
54 Fcmp, | 55 Fcmp, |
55 Icmp, | 56 Icmp, |
56 IntrinsicCall, | 57 IntrinsicCall, |
57 InsertElement, | 58 InsertElement, |
58 Load, | 59 Load, |
59 Phi, | 60 Phi, |
60 Ret, | 61 Ret, |
61 Select, | 62 Select, |
62 Store, | 63 Store, |
63 Switch, | 64 Switch, |
64 Assign, // not part of LLVM/PNaCl bitcode | 65 Assign, // not part of LLVM/PNaCl bitcode |
65 Breakpoint, // not part of LLVM/PNaCl bitcode | 66 Breakpoint, // not part of LLVM/PNaCl bitcode |
66 BundleLock, // not part of LLVM/PNaCl bitcode | 67 BundleLock, // not part of LLVM/PNaCl bitcode |
67 BundleUnlock, // not part of LLVM/PNaCl bitcode | 68 BundleUnlock, // not part of LLVM/PNaCl bitcode |
68 FakeDef, // not part of LLVM/PNaCl bitcode | 69 FakeDef, // not part of LLVM/PNaCl bitcode |
69 FakeUse, // not part of LLVM/PNaCl bitcode | 70 FakeUse, // not part of LLVM/PNaCl bitcode |
70 FakeKill, // not part of LLVM/PNaCl bitcode | 71 FakeKill, // not part of LLVM/PNaCl bitcode |
71 JumpTable, // not part of LLVM/PNaCl bitcode | 72 JumpTable, // not part of LLVM/PNaCl bitcode |
| 73 ShuffleVector, // not part of LLVM/PNaCl bitcode |
72 // Anything >= Target is an InstTarget subclass. Note that the value-spaces | 74 // Anything >= Target is an InstTarget subclass. Note that the value-spaces |
73 // are shared across targets. To avoid confusion over the definition of | 75 // are shared across targets. To avoid confusion over the definition of |
74 // shared values, an object specific to one target should never be passed | 76 // shared values, an object specific to one target should never be passed |
75 // to a different target. | 77 // to a different target. |
76 Target, | 78 Target, |
77 Target_Max = std::numeric_limits<uint8_t>::max(), | 79 Target_Max = std::numeric_limits<uint8_t>::max(), |
78 }; | 80 }; |
79 static_assert(Target <= Target_Max, "Must not be above max."); | 81 static_assert(Target <= Target_Max, "Must not be above max."); |
80 InstKind getKind() const { return Kind; } | 82 InstKind getKind() const { return Kind; } |
81 virtual const char *getInstName() const; | 83 virtual const char *getInstName() const; |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 return Instr->getKind() == FakeKill; | 912 return Instr->getKind() == FakeKill; |
911 } | 913 } |
912 | 914 |
913 private: | 915 private: |
914 InstFakeKill(Cfg *Func, const Inst *Linked); | 916 InstFakeKill(Cfg *Func, const Inst *Linked); |
915 | 917 |
916 /// This instruction is ignored if Linked->isDeleted() is true. | 918 /// This instruction is ignored if Linked->isDeleted() is true. |
917 const Inst *Linked; | 919 const Inst *Linked; |
918 }; | 920 }; |
919 | 921 |
| 922 /// ShuffleVector instruction. This represents a shuffle operation on vector |
| 923 /// types. This instruction is not part of the PNaCl bitcode: it is generated |
| 924 /// by Subzero when it matches the pattern used by pnacl-clang when compiling |
| 925 /// to bitcode. |
| 926 class InstShuffleVector : public InstHighLevel { |
| 927 InstShuffleVector() = delete; |
| 928 InstShuffleVector(const InstShuffleVector &) = delete; |
| 929 InstShuffleVector &operator=(const InstShuffleVector &) = delete; |
| 930 |
| 931 public: |
| 932 static InstShuffleVector *create(Cfg *Func, Variable *Dest, Variable *Src0, |
| 933 Variable *Src1) { |
| 934 return new (Func->allocate<InstShuffleVector>()) |
| 935 InstShuffleVector(Func, Dest, Src0, Src1); |
| 936 } |
| 937 |
| 938 SizeT getNumIndexes() const { return NumIndexes; } |
| 939 |
| 940 void addIndex(ConstantInteger32 *Index) { |
| 941 assert(CurrentIndex < NumIndexes); |
| 942 Indexes[CurrentIndex++] = Index; |
| 943 } |
| 944 |
| 945 ConstantInteger32 *getIndex(SizeT Pos) const { |
| 946 assert(Pos < NumIndexes); |
| 947 return Indexes[Pos]; |
| 948 } |
| 949 |
| 950 void dump(const Cfg *Func) const override; |
| 951 static bool classof(const Inst *Instr) { |
| 952 return Instr->getKind() == ShuffleVector; |
| 953 } |
| 954 |
| 955 private: |
| 956 InstShuffleVector(Cfg *Func, Variable *Dest, Variable *Src0, Variable *Src1); |
| 957 |
| 958 void destroy(Cfg *Func) override { |
| 959 Func->deallocateArrayOf<ConstantInteger32 *>(Indexes); |
| 960 Inst::destroy(Func); |
| 961 } |
| 962 |
| 963 ConstantInteger32 **Indexes; |
| 964 SizeT CurrentIndex = 0; |
| 965 const SizeT NumIndexes; |
| 966 }; |
| 967 |
920 /// JumpTable instruction. This represents a jump table that will be stored in | 968 /// JumpTable instruction. This represents a jump table that will be stored in |
921 /// the .rodata section. This is used to track and repoint the target CfgNodes | 969 /// the .rodata section. This is used to track and repoint the target CfgNodes |
922 /// which may change, for example due to splitting for phi lowering. | 970 /// which may change, for example due to splitting for phi lowering. |
923 class InstJumpTable : public InstHighLevel { | 971 class InstJumpTable : public InstHighLevel { |
924 InstJumpTable() = delete; | 972 InstJumpTable() = delete; |
925 InstJumpTable(const InstJumpTable &) = delete; | 973 InstJumpTable(const InstJumpTable &) = delete; |
926 InstJumpTable &operator=(const InstJumpTable &) = delete; | 974 InstJumpTable &operator=(const InstJumpTable &) = delete; |
927 | 975 |
928 public: | 976 public: |
929 static InstJumpTable *create(Cfg *Func, SizeT NumTargets, CfgNode *Default) { | 977 static InstJumpTable *create(Cfg *Func, SizeT NumTargets, CfgNode *Default) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 static void noteHead(Ice::Inst *, Ice::Inst *) {} | 1087 static void noteHead(Ice::Inst *, Ice::Inst *) {} |
1040 void deleteNode(Ice::Inst *) {} | 1088 void deleteNode(Ice::Inst *) {} |
1041 | 1089 |
1042 private: | 1090 private: |
1043 mutable ilist_half_node<Ice::Inst> Sentinel; | 1091 mutable ilist_half_node<Ice::Inst> Sentinel; |
1044 }; | 1092 }; |
1045 | 1093 |
1046 } // end of namespace llvm | 1094 } // end of namespace llvm |
1047 | 1095 |
1048 #endif // SUBZERO_SRC_ICEINST_H | 1096 #endif // SUBZERO_SRC_ICEINST_H |
OLD | NEW |