| 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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 SizeT getId() const { return Id; } | 935 SizeT getId() const { return Id; } |
| 935 SizeT getNumTargets() const { return NumTargets; } | 936 SizeT getNumTargets() const { return NumTargets; } |
| 936 CfgNode *getTarget(SizeT I) const { | 937 CfgNode *getTarget(SizeT I) const { |
| 937 assert(I < NumTargets); | 938 assert(I < NumTargets); |
| 938 return Targets[I]; | 939 return Targets[I]; |
| 939 } | 940 } |
| 940 void dump(const Cfg *Func) const override; | 941 void dump(const Cfg *Func) const override; |
| 941 static bool classof(const Inst *Instr) { | 942 static bool classof(const Inst *Instr) { |
| 942 return Instr->getKind() == JumpTable; | 943 return Instr->getKind() == JumpTable; |
| 943 } | 944 } |
| 945 // Creates a JumpDataTable struct (used for ELF emission) that represents this |
| 946 // InstJumpTable. |
| 947 JumpTableData toJumpTableData(Assembler *Asm) const; |
| 944 | 948 |
| 945 // TODO(stichnot): Should this create&save GlobalString values? | 949 // InstJumpTable is just a placeholder for the switch targets, and it does not |
| 946 static std::string makeName(GlobalString FuncName, SizeT Id) { | 950 // need to emit any code, so we redefine emit and emitIAS to do nothing. |
| 947 if (FuncName.hasStdString()) | 951 void emit(const Cfg *) const override {} |
| 948 return ".L" + FuncName + "$jumptable$__" + std::to_string(Id); | 952 void emitIAS(const Cfg * /* Func */) const override {} |
| 949 return ".L" + std::to_string(FuncName.getID()) + "_" + std::to_string(Id); | 953 |
| 954 const std::string getName() const { |
| 955 assert(Name.hasStdString()); |
| 956 return Name.toString(); |
| 950 } | 957 } |
| 951 | 958 |
| 952 private: | 959 private: |
| 953 InstJumpTable(Cfg *Func, SizeT NumTargets, CfgNode *Default); | 960 InstJumpTable(Cfg *Func, SizeT NumTargets, CfgNode *Default); |
| 954 void destroy(Cfg *Func) override { | 961 void destroy(Cfg *Func) override { |
| 955 Func->deallocateArrayOf<CfgNode *>(Targets); | 962 Func->deallocateArrayOf<CfgNode *>(Targets); |
| 956 Inst::destroy(Func); | 963 Inst::destroy(Func); |
| 957 } | 964 } |
| 958 | 965 |
| 959 const SizeT Id; | 966 const SizeT Id; |
| 960 const SizeT NumTargets; | 967 const SizeT NumTargets; |
| 961 CfgNode **Targets; | 968 CfgNode **Targets; |
| 969 GlobalString Name; // This JumpTable's name in the output. |
| 970 GlobalString FuncName; |
| 962 }; | 971 }; |
| 963 | 972 |
| 964 /// The Target instruction is the base class for all target-specific | 973 /// The Target instruction is the base class for all target-specific |
| 965 /// instructions. | 974 /// instructions. |
| 966 class InstTarget : public Inst { | 975 class InstTarget : public Inst { |
| 967 InstTarget() = delete; | 976 InstTarget() = delete; |
| 968 InstTarget(const InstTarget &) = delete; | 977 InstTarget(const InstTarget &) = delete; |
| 969 InstTarget &operator=(const InstTarget &) = delete; | 978 InstTarget &operator=(const InstTarget &) = delete; |
| 970 | 979 |
| 971 public: | 980 public: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1000 static void noteHead(Ice::Inst *, Ice::Inst *) {} | 1009 static void noteHead(Ice::Inst *, Ice::Inst *) {} |
| 1001 void deleteNode(Ice::Inst *) {} | 1010 void deleteNode(Ice::Inst *) {} |
| 1002 | 1011 |
| 1003 private: | 1012 private: |
| 1004 mutable ilist_half_node<Ice::Inst> Sentinel; | 1013 mutable ilist_half_node<Ice::Inst> Sentinel; |
| 1005 }; | 1014 }; |
| 1006 | 1015 |
| 1007 } // end of namespace llvm | 1016 } // end of namespace llvm |
| 1008 | 1017 |
| 1009 #endif // SUBZERO_SRC_ICEINST_H | 1018 #endif // SUBZERO_SRC_ICEINST_H |
| OLD | NEW |