| 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 "IceSwitchLowering.h" |
| 25 #include "IceTypes.h" | 26 #include "IceTypes.h" |
| 26 | 27 |
| 27 // TODO: The Cfg structure, and instructions in particular, need to be | 28 // TODO: The Cfg structure, and instructions in particular, need to be |
| 28 // validated for things like valid operand types, valid branch targets, proper | 29 // validated for things like valid operand types, valid branch targets, proper |
| 29 // ordering of Phi and non-Phi instructions, etc. Most of the validity checking | 30 // ordering of Phi and non-Phi instructions, etc. Most of the validity checking |
| 30 // will be done in the bitcode reader. We need a list of everything that should | 31 // will be done in the bitcode reader. We need a list of everything that should |
| 31 // be validated, and tests for each. | 32 // be validated, and tests for each. |
| 32 | 33 |
| 33 namespace Ice { | 34 namespace Ice { |
| 34 | 35 |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 SizeT getId() const { return Id; } | 937 SizeT getId() const { return Id; } |
| 937 SizeT getNumTargets() const { return NumTargets; } | 938 SizeT getNumTargets() const { return NumTargets; } |
| 938 CfgNode *getTarget(SizeT I) const { | 939 CfgNode *getTarget(SizeT I) const { |
| 939 assert(I < NumTargets); | 940 assert(I < NumTargets); |
| 940 return Targets[I]; | 941 return Targets[I]; |
| 941 } | 942 } |
| 942 void dump(const Cfg *Func) const override; | 943 void dump(const Cfg *Func) const override; |
| 943 static bool classof(const Inst *Instr) { | 944 static bool classof(const Inst *Instr) { |
| 944 return Instr->getKind() == JumpTable; | 945 return Instr->getKind() == JumpTable; |
| 945 } | 946 } |
| 947 // Creates a JumpTableData struct (used for ELF emission) that represents this |
| 948 // InstJumpTable. |
| 949 JumpTableData toJumpTableData(Assembler *Asm) const; |
| 946 | 950 |
| 947 // TODO(stichnot): Should this create&save GlobalString values? | 951 // InstJumpTable is just a placeholder for the switch targets, and it does not |
| 948 static std::string makeName(GlobalString FuncName, SizeT Id) { | 952 // need to emit any code, so we redefine emit and emitIAS to do nothing. |
| 949 if (FuncName.hasStdString()) | 953 void emit(const Cfg *) const override {} |
| 950 return ".L" + FuncName + "$jumptable$__" + std::to_string(Id); | 954 void emitIAS(const Cfg * /* Func */) const override {} |
| 951 return ".L" + std::to_string(FuncName.getID()) + "_" + std::to_string(Id); | 955 |
| 956 const std::string getName() const { |
| 957 assert(Name.hasStdString()); |
| 958 return Name.toString(); |
| 959 } |
| 960 |
| 961 std::string getSectionName() const { |
| 962 return JumpTableData::createSectionName(FuncName); |
| 952 } | 963 } |
| 953 | 964 |
| 954 private: | 965 private: |
| 955 InstJumpTable(Cfg *Func, SizeT NumTargets, CfgNode *Default); | 966 InstJumpTable(Cfg *Func, SizeT NumTargets, CfgNode *Default); |
| 956 void destroy(Cfg *Func) override { | 967 void destroy(Cfg *Func) override { |
| 957 Func->deallocateArrayOf<CfgNode *>(Targets); | 968 Func->deallocateArrayOf<CfgNode *>(Targets); |
| 958 Inst::destroy(Func); | 969 Inst::destroy(Func); |
| 959 } | 970 } |
| 960 | 971 |
| 961 const SizeT Id; | 972 const SizeT Id; |
| 962 const SizeT NumTargets; | 973 const SizeT NumTargets; |
| 963 CfgNode **Targets; | 974 CfgNode **Targets; |
| 975 GlobalString Name; // This JumpTable's name in the output. |
| 976 GlobalString FuncName; |
| 964 }; | 977 }; |
| 965 | 978 |
| 966 /// The Target instruction is the base class for all target-specific | 979 /// The Target instruction is the base class for all target-specific |
| 967 /// instructions. | 980 /// instructions. |
| 968 class InstTarget : public Inst { | 981 class InstTarget : public Inst { |
| 969 InstTarget() = delete; | 982 InstTarget() = delete; |
| 970 InstTarget(const InstTarget &) = delete; | 983 InstTarget(const InstTarget &) = delete; |
| 971 InstTarget &operator=(const InstTarget &) = delete; | 984 InstTarget &operator=(const InstTarget &) = delete; |
| 972 | 985 |
| 973 public: | 986 public: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1002 static void noteHead(Ice::Inst *, Ice::Inst *) {} | 1015 static void noteHead(Ice::Inst *, Ice::Inst *) {} |
| 1003 void deleteNode(Ice::Inst *) {} | 1016 void deleteNode(Ice::Inst *) {} |
| 1004 | 1017 |
| 1005 private: | 1018 private: |
| 1006 mutable ilist_half_node<Ice::Inst> Sentinel; | 1019 mutable ilist_half_node<Ice::Inst> Sentinel; |
| 1007 }; | 1020 }; |
| 1008 | 1021 |
| 1009 } // end of namespace llvm | 1022 } // end of namespace llvm |
| 1010 | 1023 |
| 1011 #endif // SUBZERO_SRC_ICEINST_H | 1024 #endif // SUBZERO_SRC_ICEINST_H |
| OLD | NEW |