Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1 | //===- subzero/src/IceTargetLowering.h - Lowering interface -----*- C++ -*-===// |
| 2 | // |
| 3 | // The Subzero Code Generator |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Jim Stichnoth | bbca754 | 2015-02-11 16:08:31 -0800 | [diff] [blame] | 10 | // This file declares the TargetLowering, LoweringContext, and |
| 11 | // TargetDataLowering classes. TargetLowering is an abstract class |
| 12 | // used to drive the translation/lowering process. LoweringContext |
| 13 | // maintains a context for lowering each instruction, offering |
| 14 | // conveniences such as iterating over non-deleted instructions. |
| 15 | // TargetDataLowering is an abstract class used to drive the |
| 16 | // lowering/emission of global initializers, external global |
| 17 | // declarations, and internal constant pools. |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 18 | // |
| 19 | //===----------------------------------------------------------------------===// |
| 20 | |
| 21 | #ifndef SUBZERO_SRC_ICETARGETLOWERING_H |
| 22 | #define SUBZERO_SRC_ICETARGETLOWERING_H |
| 23 | |
| 24 | #include "IceDefs.h" |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 25 | #include "IceInst.h" // for the names of the Inst subtypes |
Jim Stichnoth | a18cc9c | 2014-09-30 19:10:22 -0700 | [diff] [blame] | 26 | #include "IceTypes.h" |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 27 | |
| 28 | namespace Ice { |
| 29 | |
| 30 | // LoweringContext makes it easy to iterate through non-deleted |
| 31 | // instructions in a node, and insert new (lowered) instructions at |
| 32 | // the current point. Along with the instruction list container and |
| 33 | // associated iterators, it holds the current node, which is needed |
| 34 | // when inserting new instructions in order to track whether variables |
| 35 | // are used as single-block or multi-block. |
| 36 | class LoweringContext { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 37 | LoweringContext(const LoweringContext &) = delete; |
| 38 | LoweringContext &operator=(const LoweringContext &) = delete; |
| 39 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 40 | public: |
Jim Stichnoth | ae95320 | 2014-12-20 06:17:49 -0800 | [diff] [blame] | 41 | LoweringContext() : Node(nullptr), LastInserted(nullptr) {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 42 | ~LoweringContext() {} |
| 43 | void init(CfgNode *Node); |
| 44 | Inst *getNextInst() const { |
| 45 | if (Next == End) |
Jim Stichnoth | ae95320 | 2014-12-20 06:17:49 -0800 | [diff] [blame] | 46 | return nullptr; |
Jim Stichnoth | 607e9f0 | 2014-11-06 13:32:05 -0800 | [diff] [blame] | 47 | return Next; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 48 | } |
Jan Voung | c820ddf | 2014-07-29 14:38:51 -0700 | [diff] [blame] | 49 | Inst *getNextInst(InstList::iterator &Iter) const { |
Jan Voung | e6e497d | 2014-07-30 10:06:03 -0700 | [diff] [blame] | 50 | advanceForward(Iter); |
Jan Voung | c820ddf | 2014-07-29 14:38:51 -0700 | [diff] [blame] | 51 | if (Iter == End) |
Jim Stichnoth | ae95320 | 2014-12-20 06:17:49 -0800 | [diff] [blame] | 52 | return nullptr; |
Jim Stichnoth | 607e9f0 | 2014-11-06 13:32:05 -0800 | [diff] [blame] | 53 | return Iter; |
Jan Voung | c820ddf | 2014-07-29 14:38:51 -0700 | [diff] [blame] | 54 | } |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 55 | CfgNode *getNode() const { return Node; } |
| 56 | bool atEnd() const { return Cur == End; } |
| 57 | InstList::iterator getCur() const { return Cur; } |
Jim Stichnoth | 5d2fa0c | 2014-12-01 09:30:55 -0800 | [diff] [blame] | 58 | InstList::iterator getNext() const { return Next; } |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 59 | InstList::iterator getEnd() const { return End; } |
| 60 | void insert(Inst *Inst); |
Jan Voung | e6e497d | 2014-07-30 10:06:03 -0700 | [diff] [blame] | 61 | Inst *getLastInserted() const; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 62 | void advanceCur() { Cur = Next; } |
Jan Voung | e6e497d | 2014-07-30 10:06:03 -0700 | [diff] [blame] | 63 | void advanceNext() { advanceForward(Next); } |
Jim Stichnoth | 336f6c4 | 2014-10-30 15:01:31 -0700 | [diff] [blame] | 64 | void rewind(); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 65 | void setInsertPoint(const InstList::iterator &Position) { Next = Position; } |
| 66 | |
| 67 | private: |
| 68 | // Node is the argument to Inst::updateVars(). |
| 69 | CfgNode *Node; |
Jim Stichnoth | 98712a3 | 2014-10-24 10:59:02 -0700 | [diff] [blame] | 70 | Inst *LastInserted; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 71 | // Cur points to the current instruction being considered. It is |
| 72 | // guaranteed to point to a non-deleted instruction, or to be End. |
| 73 | InstList::iterator Cur; |
| 74 | // Next doubles as a pointer to the next valid instruction (if any), |
| 75 | // and the new-instruction insertion point. It is also updated for |
| 76 | // the caller in case the lowering consumes more than one high-level |
| 77 | // instruction. It is guaranteed to point to a non-deleted |
| 78 | // instruction after Cur, or to be End. TODO: Consider separating |
| 79 | // the notion of "next valid instruction" and "new instruction |
| 80 | // insertion point", to avoid confusion when previously-deleted |
| 81 | // instructions come between the two points. |
| 82 | InstList::iterator Next; |
Jan Voung | e6e497d | 2014-07-30 10:06:03 -0700 | [diff] [blame] | 83 | // Begin is a copy of Insts.begin(), used if iterators are moved backward. |
| 84 | InstList::iterator Begin; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 85 | // End is a copy of Insts.end(), used if Next needs to be advanced. |
| 86 | InstList::iterator End; |
| 87 | |
Jan Voung | c820ddf | 2014-07-29 14:38:51 -0700 | [diff] [blame] | 88 | void skipDeleted(InstList::iterator &I) const; |
Jan Voung | e6e497d | 2014-07-30 10:06:03 -0700 | [diff] [blame] | 89 | void advanceForward(InstList::iterator &I) const; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | class TargetLowering { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 93 | TargetLowering() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 94 | TargetLowering(const TargetLowering &) = delete; |
| 95 | TargetLowering &operator=(const TargetLowering &) = delete; |
| 96 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 97 | public: |
Jan Voung | b36ad9b | 2015-04-21 17:01:49 -0700 | [diff] [blame^] | 98 | // TODO(jvoung): return a unique_ptr like the other factory functions. |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 99 | static TargetLowering *createLowering(TargetArch Target, Cfg *Func); |
Jan Voung | ec27073 | 2015-01-12 17:00:22 -0800 | [diff] [blame] | 100 | static std::unique_ptr<Assembler> createAssembler(TargetArch Target, |
| 101 | Cfg *Func); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 102 | void translate() { |
Jan Voung | 1f47ad0 | 2015-03-20 15:01:26 -0700 | [diff] [blame] | 103 | switch (Ctx->getFlags().getOptLevel()) { |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 104 | case Opt_m1: |
| 105 | translateOm1(); |
| 106 | break; |
| 107 | case Opt_0: |
| 108 | translateO0(); |
| 109 | break; |
| 110 | case Opt_1: |
| 111 | translateO1(); |
| 112 | break; |
| 113 | case Opt_2: |
| 114 | translateO2(); |
| 115 | break; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 116 | } |
| 117 | } |
| 118 | virtual void translateOm1() { |
| 119 | Func->setError("Target doesn't specify Om1 lowering steps."); |
| 120 | } |
| 121 | virtual void translateO0() { |
| 122 | Func->setError("Target doesn't specify O0 lowering steps."); |
| 123 | } |
| 124 | virtual void translateO1() { |
| 125 | Func->setError("Target doesn't specify O1 lowering steps."); |
| 126 | } |
| 127 | virtual void translateO2() { |
| 128 | Func->setError("Target doesn't specify O2 lowering steps."); |
| 129 | } |
| 130 | |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 131 | // Tries to do address mode optimization on a single instruction. |
| 132 | void doAddressOpt(); |
Matt Wala | c330274 | 2014-08-15 16:21:56 -0700 | [diff] [blame] | 133 | // Randomly insert NOPs. |
| 134 | void doNopInsertion(); |
Jim Stichnoth | 336f6c4 | 2014-10-30 15:01:31 -0700 | [diff] [blame] | 135 | // Lowers a single non-Phi instruction. |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 136 | void lower(); |
Jim Stichnoth | 336f6c4 | 2014-10-30 15:01:31 -0700 | [diff] [blame] | 137 | // Does preliminary lowering of the set of Phi instructions in the |
| 138 | // current node. The main intention is to do what's needed to keep |
| 139 | // the unlowered Phi instructions consistent with the lowered |
| 140 | // non-Phi instructions, e.g. to lower 64-bit operands on a 32-bit |
| 141 | // target. |
| 142 | virtual void prelowerPhis() {} |
| 143 | // Lowers a list of "parallel" assignment instructions representing |
| 144 | // a topological sort of the Phi instructions. |
| 145 | virtual void lowerPhiAssignments(CfgNode *Node, |
| 146 | const AssignList &Assignments) = 0; |
Jim Stichnoth | ff9c706 | 2014-09-18 04:50:49 -0700 | [diff] [blame] | 147 | // Tries to do branch optimization on a single instruction. Returns |
| 148 | // true if some optimization was done. |
| 149 | virtual bool doBranchOpt(Inst * /*I*/, const CfgNode * /*NextNode*/) { |
| 150 | return false; |
| 151 | } |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 152 | |
Jim Stichnoth | 3d44fe8 | 2014-11-01 10:10:18 -0700 | [diff] [blame] | 153 | virtual SizeT getNumRegisters() const = 0; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 154 | // Returns a variable pre-colored to the specified physical |
| 155 | // register. This is generally used to get very direct access to |
| 156 | // the register such as in the prolog or epilog or for marking |
Jim Stichnoth | 98712a3 | 2014-10-24 10:59:02 -0700 | [diff] [blame] | 157 | // scratch registers as killed by a call. If a Type is not |
| 158 | // provided, a target-specific default type is used. |
| 159 | virtual Variable *getPhysicalRegister(SizeT RegNum, |
| 160 | Type Ty = IceType_void) = 0; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 161 | // Returns a printable name for the register. |
| 162 | virtual IceString getRegName(SizeT RegNum, Type Ty) const = 0; |
| 163 | |
| 164 | virtual bool hasFramePointer() const { return false; } |
| 165 | virtual SizeT getFrameOrStackReg() const = 0; |
Matt Wala | d4799f4 | 2014-08-14 14:24:12 -0700 | [diff] [blame] | 166 | virtual size_t typeWidthInBytesOnStack(Type Ty) const = 0; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 167 | bool hasComputedFrame() const { return HasComputedFrame; } |
Jan Voung | 44d53e1 | 2014-09-11 19:18:03 -0700 | [diff] [blame] | 168 | // Returns true if this function calls a function that has the |
| 169 | // "returns twice" attribute. |
| 170 | bool callsReturnsTwice() const { return CallsReturnsTwice; } |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 171 | void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; } |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 172 | int32_t getStackAdjustment() const { return StackAdjustment; } |
| 173 | void updateStackAdjustment(int32_t Offset) { StackAdjustment += Offset; } |
| 174 | void resetStackAdjustment() { StackAdjustment = 0; } |
Jan Voung | b36ad9b | 2015-04-21 17:01:49 -0700 | [diff] [blame^] | 175 | SizeT makeNextLabelNumber() { return NextLabelNumber++; } |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 176 | LoweringContext &getContext() { return Context; } |
| 177 | |
| 178 | enum RegSet { |
| 179 | RegSet_None = 0, |
| 180 | RegSet_CallerSave = 1 << 0, |
| 181 | RegSet_CalleeSave = 1 << 1, |
| 182 | RegSet_StackPointer = 1 << 2, |
| 183 | RegSet_FramePointer = 1 << 3, |
| 184 | RegSet_All = ~RegSet_None |
| 185 | }; |
| 186 | typedef uint32_t RegSetMask; |
| 187 | |
| 188 | virtual llvm::SmallBitVector getRegisterSet(RegSetMask Include, |
| 189 | RegSetMask Exclude) const = 0; |
| 190 | virtual const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const = 0; |
Jim Stichnoth | 70d0a05 | 2014-11-14 15:53:46 -0800 | [diff] [blame] | 191 | void regAlloc(RegAllocKind Kind); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 192 | |
Jim Stichnoth | e6d2478 | 2014-12-19 05:42:24 -0800 | [diff] [blame] | 193 | virtual void makeRandomRegisterPermutation( |
| 194 | llvm::SmallVectorImpl<int32_t> &Permutation, |
| 195 | const llvm::SmallBitVector &ExcludeRegisters) const = 0; |
| 196 | |
Jim Stichnoth | 9738a9e | 2015-02-23 16:39:06 -0800 | [diff] [blame] | 197 | // Save/restore any mutable state for the situation where code |
| 198 | // emission needs multiple passes, such as sandboxing or relaxation. |
| 199 | // Subclasses may provide their own implementation, but should be |
| 200 | // sure to also call the parent class's methods. |
| 201 | virtual void snapshotEmitState() { |
| 202 | SnapshotStackAdjustment = StackAdjustment; |
| 203 | } |
| 204 | virtual void rollbackEmitState() { |
| 205 | StackAdjustment = SnapshotStackAdjustment; |
| 206 | } |
| 207 | |
Jim Stichnoth | 144cdce | 2014-09-22 16:02:59 -0700 | [diff] [blame] | 208 | virtual void emitVariable(const Variable *Var) const = 0; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 209 | |
Matt Wala | 45a0623 | 2014-07-09 16:33:22 -0700 | [diff] [blame] | 210 | // Performs target-specific argument lowering. |
| 211 | virtual void lowerArguments() = 0; |
| 212 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 213 | virtual void addProlog(CfgNode *Node) = 0; |
| 214 | virtual void addEpilog(CfgNode *Node) = 0; |
| 215 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 216 | virtual ~TargetLowering() {} |
| 217 | |
| 218 | protected: |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 219 | explicit TargetLowering(Cfg *Func); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 220 | virtual void lowerAlloca(const InstAlloca *Inst) = 0; |
| 221 | virtual void lowerArithmetic(const InstArithmetic *Inst) = 0; |
| 222 | virtual void lowerAssign(const InstAssign *Inst) = 0; |
| 223 | virtual void lowerBr(const InstBr *Inst) = 0; |
| 224 | virtual void lowerCall(const InstCall *Inst) = 0; |
| 225 | virtual void lowerCast(const InstCast *Inst) = 0; |
| 226 | virtual void lowerFcmp(const InstFcmp *Inst) = 0; |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 227 | virtual void lowerExtractElement(const InstExtractElement *Inst) = 0; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 228 | virtual void lowerIcmp(const InstIcmp *Inst) = 0; |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 229 | virtual void lowerInsertElement(const InstInsertElement *Inst) = 0; |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 230 | virtual void lowerIntrinsicCall(const InstIntrinsicCall *Inst) = 0; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 231 | virtual void lowerLoad(const InstLoad *Inst) = 0; |
| 232 | virtual void lowerPhi(const InstPhi *Inst) = 0; |
| 233 | virtual void lowerRet(const InstRet *Inst) = 0; |
| 234 | virtual void lowerSelect(const InstSelect *Inst) = 0; |
| 235 | virtual void lowerStore(const InstStore *Inst) = 0; |
| 236 | virtual void lowerSwitch(const InstSwitch *Inst) = 0; |
| 237 | virtual void lowerUnreachable(const InstUnreachable *Inst) = 0; |
| 238 | |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 239 | virtual void doAddressOptLoad() {} |
| 240 | virtual void doAddressOptStore() {} |
Matt Wala | c330274 | 2014-08-15 16:21:56 -0700 | [diff] [blame] | 241 | virtual void randomlyInsertNop(float Probability) = 0; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 242 | // This gives the target an opportunity to post-process the lowered |
Jim Stichnoth | 70d0a05 | 2014-11-14 15:53:46 -0800 | [diff] [blame] | 243 | // expansion before returning. |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 244 | virtual void postLower() {} |
| 245 | |
Jan Voung | b36ad9b | 2015-04-21 17:01:49 -0700 | [diff] [blame^] | 246 | // Make a call to an external helper function. |
| 247 | InstCall *makeHelperCall(const IceString &Name, Variable *Dest, |
| 248 | SizeT MaxSrcs); |
| 249 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 250 | Cfg *Func; |
| 251 | GlobalContext *Ctx; |
| 252 | bool HasComputedFrame; |
Jan Voung | 44d53e1 | 2014-09-11 19:18:03 -0700 | [diff] [blame] | 253 | bool CallsReturnsTwice; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 254 | // StackAdjustment keeps track of the current stack offset from its |
| 255 | // natural location, as arguments are pushed for a function call. |
| 256 | int32_t StackAdjustment; |
Jan Voung | b36ad9b | 2015-04-21 17:01:49 -0700 | [diff] [blame^] | 257 | SizeT NextLabelNumber; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 258 | LoweringContext Context; |
Jim Stichnoth | 9738a9e | 2015-02-23 16:39:06 -0800 | [diff] [blame] | 259 | |
Jim Stichnoth | c450879 | 2015-03-01 23:12:55 -0800 | [diff] [blame] | 260 | // Runtime helper function names |
| 261 | const static constexpr char *H_bitcast_16xi1_i16 = "__Sz_bitcast_16xi1_i16"; |
| 262 | const static constexpr char *H_bitcast_8xi1_i8 = "__Sz_bitcast_8xi1_i8"; |
| 263 | const static constexpr char *H_bitcast_i16_16xi1 = "__Sz_bitcast_i16_16xi1"; |
| 264 | const static constexpr char *H_bitcast_i8_8xi1 = "__Sz_bitcast_i8_8xi1"; |
| 265 | const static constexpr char *H_call_ctpop_i32 = "__popcountsi2"; |
| 266 | const static constexpr char *H_call_ctpop_i64 = "__popcountdi2"; |
| 267 | const static constexpr char *H_call_longjmp = "longjmp"; |
| 268 | const static constexpr char *H_call_memcpy = "memcpy"; |
| 269 | const static constexpr char *H_call_memmove = "memmove"; |
| 270 | const static constexpr char *H_call_memset = "memset"; |
| 271 | const static constexpr char *H_call_read_tp = "__nacl_read_tp"; |
| 272 | const static constexpr char *H_call_setjmp = "setjmp"; |
| 273 | const static constexpr char *H_fptosi_f32_i64 = "__Sz_fptosi_f32_i64"; |
| 274 | const static constexpr char *H_fptosi_f64_i64 = "__Sz_fptosi_f64_i64"; |
| 275 | const static constexpr char *H_fptoui_4xi32_f32 = "__Sz_fptoui_4xi32_f32"; |
| 276 | const static constexpr char *H_fptoui_f32_i32 = "__Sz_fptoui_f32_i32"; |
| 277 | const static constexpr char *H_fptoui_f32_i64 = "__Sz_fptoui_f32_i64"; |
| 278 | const static constexpr char *H_fptoui_f64_i32 = "__Sz_fptoui_f64_i32"; |
| 279 | const static constexpr char *H_fptoui_f64_i64 = "__Sz_fptoui_f64_i64"; |
| 280 | const static constexpr char *H_frem_f32 = "fmodf"; |
| 281 | const static constexpr char *H_frem_f64 = "fmod"; |
| 282 | const static constexpr char *H_sdiv_i64 = "__divdi3"; |
| 283 | const static constexpr char *H_sitofp_i64_f32 = "__Sz_sitofp_i64_f32"; |
| 284 | const static constexpr char *H_sitofp_i64_f64 = "__Sz_sitofp_i64_f64"; |
| 285 | const static constexpr char *H_srem_i64 = "__moddi3"; |
| 286 | const static constexpr char *H_udiv_i64 = "__udivdi3"; |
| 287 | const static constexpr char *H_uitofp_4xi32_4xf32 = "__Sz_uitofp_4xi32_4xf32"; |
| 288 | const static constexpr char *H_uitofp_i32_f32 = "__Sz_uitofp_i32_f32"; |
| 289 | const static constexpr char *H_uitofp_i32_f64 = "__Sz_uitofp_i32_f64"; |
| 290 | const static constexpr char *H_uitofp_i64_f32 = "__Sz_uitofp_i64_f32"; |
| 291 | const static constexpr char *H_uitofp_i64_f64 = "__Sz_uitofp_i64_f64"; |
| 292 | const static constexpr char *H_urem_i64 = "__umoddi3"; |
| 293 | |
Jim Stichnoth | 9738a9e | 2015-02-23 16:39:06 -0800 | [diff] [blame] | 294 | private: |
| 295 | int32_t SnapshotStackAdjustment; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 296 | }; |
| 297 | |
Jan Voung | 72984d8 | 2015-01-29 14:42:38 -0800 | [diff] [blame] | 298 | // TargetDataLowering is used for "lowering" data including initializers |
| 299 | // for global variables, and the internal constant pools. It is separated |
| 300 | // out from TargetLowering because it does not require a Cfg. |
| 301 | class TargetDataLowering { |
| 302 | TargetDataLowering() = delete; |
| 303 | TargetDataLowering(const TargetDataLowering &) = delete; |
| 304 | TargetDataLowering &operator=(const TargetDataLowering &) = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 305 | |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 306 | public: |
Jim Stichnoth | bbca754 | 2015-02-11 16:08:31 -0800 | [diff] [blame] | 307 | static std::unique_ptr<TargetDataLowering> createLowering(GlobalContext *Ctx); |
Jan Voung | 72984d8 | 2015-01-29 14:42:38 -0800 | [diff] [blame] | 308 | virtual ~TargetDataLowering(); |
Jan Voung | 839c4ce | 2014-07-28 15:19:43 -0700 | [diff] [blame] | 309 | |
Jim Stichnoth | bbca754 | 2015-02-11 16:08:31 -0800 | [diff] [blame] | 310 | virtual void |
| 311 | lowerGlobals(std::unique_ptr<VariableDeclarationList> Vars) const = 0; |
| 312 | virtual void lowerConstants() const = 0; |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 313 | |
| 314 | protected: |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 315 | explicit TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {} |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 316 | GlobalContext *Ctx; |
Jim Stichnoth | de4ca71 | 2014-06-29 08:13:48 -0700 | [diff] [blame] | 317 | }; |
| 318 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 319 | } // end of namespace Ice |
| 320 | |
| 321 | #endif // SUBZERO_SRC_ICETARGETLOWERING_H |