llvm.org GIT mirror llvm / c36e746
Reformat blank lines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248263 91177308-0d34-0410-b5e6-96231b3b80d8 NAKAMURA Takumi 5 years ago
37 changed file(s) with 156 addition(s) and 179 deletion(s). Raw diff Collapse all Expand all
2626
2727 class AssemblyAnnotationWriter {
2828 public:
29
3029 virtual ~AssemblyAnnotationWriter();
3130
3231 /// emitFunctionAnnot - This may be implemented to emit a string right before
119119
120120 EndAttrKinds ///< Sentinal value useful for loops
121121 };
122
122123 private:
123124 AttributeImpl *pImpl;
124125 Attribute(AttributeImpl *A) : pImpl(A) {}
126
125127 public:
126128 Attribute() : pImpl(nullptr) {}
127129
225227 ReturnIndex = 0U,
226228 FunctionIndex = ~0U
227229 };
230
228231 private:
229232 friend class AttrBuilder;
230233 friend class AttributeSetImpl;
248251 ArrayRef
249252 AttributeSetNode*> > Attrs);
250253
251
252254 explicit AttributeSet(AttributeSetImpl *LI) : pImpl(LI) {}
255
253256 public:
254257 AttributeSet() : pImpl(nullptr) {}
255258
438441 uint64_t StackAlignment;
439442 uint64_t DerefBytes;
440443 uint64_t DerefOrNullBytes;
444
441445 public:
442446 AttrBuilder()
443447 : Attrs(0), Alignment(0), StackAlignment(0), DerefBytes(0),
6868 }
6969 return CallSiteBase();
7070 }
71
7172 public:
7273 /// isCall - true if a CallInst is enclosed.
7374 /// Note that !isCall() does not mean it is an InvokeInst enclosed,
252253 uint64_t getDereferenceableBytes(uint16_t i) const {
253254 CALLSITE_DELEGATE_GETTER(getDereferenceableBytes(i));
254255 }
255
256
256257 /// @brief Extract the number of dereferenceable_or_null bytes for a call or
257258 /// parameter (0=unknown).
258259 uint64_t getDereferenceableOrNullBytes(uint16_t i) const {
259260 CALLSITE_DELEGATE_GETTER(getDereferenceableOrNullBytes(i));
260261 }
261
262
262263 /// \brief Return true if the call should not be treated as a call to a
263264 /// builtin.
264265 bool isNoBuiltin() const {
8484 /// isConstantUsed - Return true if the constant has users other than constant
8585 /// exprs and other dangling things.
8686 bool isConstantUsed() const;
87
87
8888 enum PossibleRelocationsTy {
8989 NoRelocation = 0,
9090 LocalRelocation = 1,
9191 GlobalRelocations = 2
9292 };
93
93
9494 /// getRelocationInfo - This method classifies the entry according to
9595 /// whether or not it may generate a relocation entry. This must be
9696 /// conservative, so if it might codegen to a relocatable entry, it should say
106106 ///
107107 /// FIXME: This really should not be in VMCore.
108108 PossibleRelocationsTy getRelocationInfo() const;
109
109
110110 /// getAggregateElement - For aggregates (struct/array/vector) return the
111111 /// constant that corresponds to the specified element if possible, or null if
112112 /// not. This can return null if the element index is a ConstantExpr, or if
206206 /// Make this range have the bit width given by \p BitWidth. The
207207 /// value is zero extended, truncated, or left alone to make it that width.
208208 ConstantRange zextOrTrunc(uint32_t BitWidth) const;
209
209
210210 /// Make this range have the bit width given by \p BitWidth. The
211211 /// value is sign extended, truncated, or left alone to make it that width.
212212 ConstantRange sextOrTrunc(uint32_t BitWidth) const;
257257 /// Return a new range that is the logical not of the current set.
258258 ///
259259 ConstantRange inverse() const;
260
260
261261 /// Print out the bounds to a stream.
262262 ///
263263 void print(raw_ostream &OS) const;
3535 /// @brief Integer representation type
3636 class IntegerType : public Type {
3737 friend class LLVMContextImpl;
38
38
3939 protected:
4040 explicit IntegerType(LLVMContext &C, unsigned NumBits) : Type(C, IntegerTyID){
4141 setSubclassData(NumBits);
4242 }
43
4344 public:
4445 /// This enum is just used to hold constants we need for IntegerType.
4546 enum {
8990 }
9091 };
9192
92
9393 /// FunctionType - Class to represent function types
9494 ///
9595 class FunctionType : public Type {
107107 /// FunctionType::get - Create a FunctionType taking no parameters.
108108 ///
109109 static FunctionType *get(Type *Result, bool isVarArg);
110
110
111111 /// isValidReturnType - Return true if the specified type is valid as a return
112112 /// type.
113113 static bool isValidReturnType(Type *RetTy);
165165 T->getTypeID() == VectorTyID;
166166 }
167167 };
168
169168
170169 /// StructType - Class to represent struct types. There are two different kinds
171170 /// of struct types: Literal structs and Identified structs.
206205 /// a identified type that has an empty name.
207206 ///
208207 void *SymbolTableEntry;
209 public:
210
208
209 public:
211210 /// StructType::create - This creates an identified struct.
212211 static StructType *create(LLVMContext &Context, StringRef Name);
213212 static StructType *create(LLVMContext &Context);
228227 /// StructType::get - Create an empty structure type.
229228 ///
230229 static StructType *get(LLVMContext &Context, bool isPacked = false);
231
230
232231 /// StructType::get - This static method is a convenience method for creating
233232 /// structure types by specifying the elements as arguments. Note that this
234233 /// method always returns a non-packed struct, and requires at least one
236235 static StructType *get(Type *elt1, ...) LLVM_END_WITH_NULL;
237236
238237 bool isPacked() const { return (getSubclassData() & SCDB_Packed) != 0; }
239
238
240239 /// isLiteral - Return true if this type is uniqued by structural
241240 /// equivalence, false if it is a struct definition.
242241 bool isLiteral() const { return (getSubclassData() & SCDB_IsLiteral) != 0; }
243
242
244243 /// isOpaque - Return true if this is a type with an identity that has no body
245244 /// specified yet. These prints as 'opaque' in .ll files.
246245 bool isOpaque() const { return (getSubclassData() & SCDB_HasBody) == 0; }
250249
251250 /// hasName - Return true if this is a named struct that has a non-empty name.
252251 bool hasName() const { return SymbolTableEntry != nullptr; }
253
252
254253 /// getName - Return the name for this struct type if it has an identity.
255254 /// This may return an empty string for an unnamed struct type. Do not call
256255 /// this on an literal type.
257256 StringRef getName() const;
258
257
259258 /// setName - Change the name of this type to the specified name, or to a name
260259 /// with a suffix if there is a collision. Do not call this on an literal
261260 /// type.
264263 /// setBody - Specify a body for an opaque identified type.
265264 void setBody(ArrayRef Elements, bool isPacked = false);
266265 void setBody(Type *elt1, ...) LLVM_END_WITH_NULL;
267
266
268267 /// isValidElementType - Return true if the specified type is valid as a
269268 /// element type.
270269 static bool isValidElementType(Type *ElemTy);
271
272270
273271 // Iterator access to the elements.
274272 typedef Type::subtype_iterator element_iterator;
326324 }
327325 };
328326
329
330327 /// ArrayType - Class to represent array types.
331328 ///
332329 class ArrayType : public SequentialType {
335332 ArrayType(const ArrayType &) = delete;
336333 const ArrayType &operator=(const ArrayType &) = delete;
337334 ArrayType(Type *ElType, uint64_t NumEl);
335
338336 public:
339337 /// ArrayType::get - This static method is the primary way to construct an
340338 /// ArrayType
361359 VectorType(const VectorType &) = delete;
362360 const VectorType &operator=(const VectorType &) = delete;
363361 VectorType(Type *ElType, unsigned NumEl);
362
364363 public:
365364 /// VectorType::get - This static method is the primary way to construct an
366365 /// VectorType.
439438 }
440439 };
441440
442
443441 /// PointerType - Class to represent pointers.
444442 ///
445443 class PointerType : public SequentialType {
446444 PointerType(const PointerType &) = delete;
447445 const PointerType &operator=(const PointerType &) = delete;
448446 explicit PointerType(Type *ElType, unsigned AddrSpace);
447
449448 public:
450449 /// PointerType::get - This constructs a pointer to an object of the specified
451450 /// type in a numbered address space.
4646 static void noteHead(Argument*, Argument*) {}
4747
4848 static ValueSymbolTable *getSymTab(Function *ItemParent);
49
4950 private:
5051 mutable ilist_half_node Sentinel;
5152 };
267268 uint64_t getDereferenceableBytes(unsigned i) const {
268269 return AttributeSets.getDereferenceableBytes(i);
269270 }
270
271
271272 /// @brief Extract the number of dereferenceable_or_null bytes for a call or
272273 /// parameter (0=unknown).
273274 uint64_t getDereferenceableOrNullBytes(unsigned i) const {
274275 return AttributeSets.getDereferenceableOrNullBytes(i);
275276 }
276
277
277278 /// @brief Determine if the function does not access memory.
278279 bool doesNotAccessMemory() const {
279280 return AttributeSets.hasAttribute(AttributeSet::FunctionIndex,
423424 ///
424425 void eraseFromParent() override;
425426
426
427427 /// Get the underlying elements of the Function... the basic block list is
428428 /// empty for external functions.
429429 ///
455455 ///
456456 inline ValueSymbolTable &getValueSymbolTable() { return *SymTab; }
457457 inline const ValueSymbolTable &getValueSymbolTable() const { return *SymTab; }
458
459458
460459 //===--------------------------------------------------------------------===//
461460 // BasicBlock iterator forwarding functions
5151 /// \brief Common base class shared among various IRBuilders.
5252 class IRBuilderBase {
5353 DebugLoc CurDbgLocation;
54
5455 protected:
5556 BasicBlock *BB;
5657 BasicBlock::iterator InsertPt;
5859
5960 MDNode *DefaultFPMathTag;
6061 FastMathFlags FMF;
62
6163 public:
62
6364 IRBuilderBase(LLVMContext &context, MDNode *FPMathTag = nullptr)
6465 : Context(context), DefaultFPMathTag(FPMathTag), FMF() {
6566 ClearInsertionPoint();
514515 typename Inserter = IRBuilderDefaultInserter >
515516 class IRBuilder : public IRBuilderBase, public Inserter {
516517 T Folder;
518
517519 public:
518520 IRBuilder(LLVMContext &C, const T &F, Inserter I = Inserter(),
519521 MDNode *FPMathTag = nullptr)
736738 I->setFastMathFlags(FMF);
737739 return I;
738740 }
741
739742 public:
740743 Value *CreateAdd(Value *LHS, Value *RHS, const Twine &Name = "",
741744 bool HasNUW = false, bool HasNSW = false) {
13711374
13721375 return CreateBitCast(V, DestTy, Name);
13731376 }
1377
13741378 private:
13751379 // \brief Provided to resolve 'CreateIntCast(Ptr, Ptr, "...")', giving a
13761380 // compile time error, instead of converting the string to bool for the
13771381 // isSigned parameter.
13781382 Value *CreateIntCast(Value *, Type *, const char *) = delete;
1383
13791384 public:
13801385 Value *CreateFPCast(Value *V, Type *DestTy, const Twine &Name = "") {
13811386 if (V->getType() == DestTy)
17391744
17401745 // Create wrappers for C Binding types (see CBindingWrapping.h).
17411746 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef)
1742
17431747 }
17441748
17451749 #endif
5656 /// When the ConstantUniqueMap merges two types and makes two InlineAsms
5757 /// identical, it destroys one of them with this method.
5858 void destroyConstant();
59
5960 public:
60
6161 /// InlineAsm::get - Return the specified uniqued inline asm string.
6262 ///
6363 static InlineAsm *get(FunctionType *Ty, StringRef AsmString,
6464 StringRef Constraints, bool hasSideEffects,
6565 bool isAlignStack = false,
6666 AsmDialect asmDialect = AD_ATT);
67
67
6868 bool hasSideEffects() const { return HasSideEffects; }
6969 bool isAlignStack() const { return IsAlignStack; }
7070 AsmDialect getDialect() const { return Dialect; }
7474 PointerType *getType() const {
7575 return reinterpret_cast(Value::getType());
7676 }
77
77
7878 /// getFunctionType - InlineAsm's are always pointers to functions.
7979 ///
8080 FunctionType *getFunctionType() const;
81
81
8282 const std::string &getAsmString() const { return AsmString; }
8383 const std::string &getConstraintString() const { return Constraints; }
8484
9494 isOutput, // '=x'
9595 isClobber // '~x'
9696 };
97
97
9898 typedef std::vector ConstraintCodeVector;
99
99
100100 struct SubConstraintInfo {
101101 /// MatchingInput - If this is not -1, this is an output constraint where an
102102 /// input constraint is required to match it (e.g. "0"). The value is the
113113 typedef std::vector SubConstraintInfoVector;
114114 struct ConstraintInfo;
115115 typedef std::vector ConstraintInfoVector;
116
116
117117 struct ConstraintInfo {
118118 /// Type - The basic type of the constraint: input/output/clobber
119119 ///
120120 ConstraintPrefix Type;
121
121
122122 /// isEarlyClobber - "&": output operand writes result before inputs are all
123123 /// read. This is only ever set for an output operand.
124124 bool isEarlyClobber;
128128 /// constraint number that matches this one (for example, if this is
129129 /// constraint #0 and constraint #4 has the value "0", this will be 4).
130130 signed char MatchingInput;
131
131
132132 /// hasMatchingInput - Return true if this is an output constraint that has
133133 /// a matching input constraint.
134134 bool hasMatchingInput() const { return MatchingInput != -1; }
135
135
136136 /// isCommutative - This is set to true for a constraint that is commutative
137137 /// with the next operand.
138138 bool isCommutative;
139
139
140140 /// isIndirect - True if this operand is an indirect operand. This means
141141 /// that the address of the source or destination is present in the call
142142 /// instruction, instead of it being returned or passed in explicitly. This
143143 /// is represented with a '*' in the asm string.
144144 bool isIndirect;
145
145
146146 /// Code - The constraint code, either the register name (in braces) or the
147147 /// constraint letter/number.
148148 ConstraintCodeVector Codes;
149
149
150150 /// isMultipleAlternative - '|': has multiple-alternative constraints.
151151 bool isMultipleAlternative;
152
152
153153 /// multipleAlternatives - If there are multiple alternative constraints,
154154 /// this array will contain them. Otherwise it will be empty.
155155 SubConstraintInfoVector multipleAlternatives;
156
156
157157 /// The currently selected alternative constraint index.
158158 unsigned currentAlternativeIndex;
159159
160160 /// Default constructor.
161161 ConstraintInfo();
162
162
163163 /// Parse - Analyze the specified string (e.g. "=*&{eax}") and fill in the
164164 /// fields in this structure. If the constraint string is not understood,
165165 /// return true, otherwise return false.
166166 bool Parse(StringRef Str, ConstraintInfoVector &ConstraintsSoFar);
167
167
168168 /// selectAlternative - Point this constraint to the alternative constraint
169169 /// indicated by the index.
170170 void selectAlternative(unsigned index);
171171 };
172
172
173173 /// ParseConstraints - Split up the constraint string into the specific
174174 /// constraints and their prefixes. If this returns an empty vector, and if
175175 /// the constraint string itself isn't empty, there was an error parsing.
180180 ConstraintInfoVector ParseConstraints() const {
181181 return ParseConstraints(Constraints);
182182 }
183
183
184184 // Methods for support type inquiry through isa, cast, and dyn_cast:
185185 static inline bool classof(const Value *V) {
186186 return V->getValueID() == Value::InlineAsmVal;
187187 }
188188
189
190189 // These are helper methods for dealing with flags in the INLINEASM SDNode
191190 // in the backend.
192191 //
203202 // code.
204203 // Else:
205204 // Bit 30-16 - The register class ID to use for the operand.
206
205
207206 enum : uint32_t {
208207 // Fixed operands on an INLINEASM SDNode.
209208 Op_InputChain = 0,
264263
265264 Flag_MatchingOperand = 0x80000000
266265 };
267
266
268267 static unsigned getFlagWord(unsigned Kind, unsigned NumOps) {
269268 assert(((NumOps << 3) & ~0xffff) == 0 && "Too many inline asm operands!");
270269 assert(Kind >= Kind_RegUse && Kind <= Kind_Mem && "Invalid Kind");
271270 return Kind | (NumOps << 3);
272271 }
273
272
274273 /// getFlagWordForMatchingOp - Augment an existing flag word returned by
275274 /// getFlagWord with information indicating that this input operand is tied
276275 /// to a previous output operand.
355354 RC = High - 1;
356355 return true;
357356 }
358
359357 };
360358
361359 } // End llvm namespace
5050 virtual BasicBlock *getSuccessorV(unsigned idx) const = 0;
5151 virtual unsigned getNumSuccessorsV() const = 0;
5252 virtual void setSuccessorV(unsigned idx, BasicBlock *B) = 0;
53
5354 public:
54
5555 /// Return the number of successors that this terminator has.
5656 unsigned getNumSuccessors() const {
5757 return getNumSuccessorsV();
270270 }
271271 };
272272
273
274273 //===----------------------------------------------------------------------===//
275274 // UnaryInstruction Class
276275 //===----------------------------------------------------------------------===//
288287 : Instruction(Ty, iType, &Op<0>(), 1, IAE) {
289288 Op<0>() = V;
290289 }
290
291291 public:
292292 // allocate space for exactly one operand
293293 void *operator new(size_t s) {
326326
327327 class BinaryOperator : public Instruction {
328328 void *operator new(size_t, unsigned) = delete;
329
329330 protected:
330331 void init(BinaryOps iType);
331332 BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
402403 BO->setHasNoSignedWrap(true);
403404 return BO;
404405 }
405
406
406407 static BinaryOperator *CreateNUW(BinaryOps Opc, Value *V1, Value *V2,
407408 const Twine &Name = "") {
408409 BinaryOperator *BO = Create(Opc, V1, V2, Name);
421422 BO->setHasNoUnsignedWrap(true);
422423 return BO;
423424 }
424
425
425426 static BinaryOperator *CreateExact(BinaryOps Opc, Value *V1, Value *V2,
426427 const Twine &Name = "") {
427428 BinaryOperator *BO = Create(Opc, V1, V2, Name);
470471 DEFINE_HELPERS(LShr, Exact) // CreateExactLShr
471472
472473 #undef DEFINE_HELPERS
473
474
474475 /// Helper functions to construct and inspect unary operations (NEG and NOT)
475476 /// via binary operators SUB and XOR:
476477 ///
548549 /// Convenience method to copy supported wrapping, exact, and fast-math flags
549550 /// from V to this instruction.
550551 void copyIRFlags(const Value *V);
551
552
552553 /// Logical 'and' of any supported wrapping, exact, and fast-math flags of
553554 /// V and this instruction.
554555 void andIRFlags(const Value *V);
581582 /// @brief Base class of casting instructions.
582583 class CastInst : public UnaryInstruction {
583584 void anchor() override;
585
584586 protected:
585587 /// @brief Constructor with insert-before-instruction semantics for subclasses
586588 CastInst(Type *Ty, unsigned iType, Value *S,
594596 : UnaryInstruction(Ty, iType, S, InsertAtEnd) {
595597 setName(NameStr);
596598 }
599
597600 public:
598601 /// Provides a way to construct any of the CastInst subclasses using an
599602 /// opcode instead of the subclass's constructor. The opcode must be in the
872875 class CmpInst : public Instruction {
873876 void *operator new(size_t, unsigned) = delete;
874877 CmpInst() = delete;
878
875879 protected:
876880 CmpInst(Type *ty, Instruction::OtherOps op, unsigned short pred,
877881 Value *LHS, Value *RHS, const Twine &Name = "",
882886 BasicBlock *InsertAtEnd);
883887
884888 void anchor() override; // Out of line virtual method.
889
885890 public:
886891 /// This enumeration lists the possible predicates for CmpInst subclasses.
887892 /// Values in the range 0-31 are reserved for FCmpInst, while values in the
968973 bool isFPPredicate() const { return isFPPredicate(getPredicate()); }
969974 bool isIntPredicate() const { return isIntPredicate(getPredicate()); }
970975
971
972976 /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE,
973977 /// OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
974978 /// @returns the inverse predicate for the instruction's current predicate.
10751079 }
10761080 return Type::getInt1Ty(opnd_type->getContext());
10771081 }
1082
10781083 private:
10791084 // Shadow Value::setValueSubclassData with a private forwarding method so that
10801085 // subclasses cannot accidentally use it.
10831088 }
10841089 };
10851090
1086
10871091 // FIXME: these are redundant if CmpInst < BinaryOperator
10881092 template <>
10891093 struct OperandTraits : public FixedNumOperandTraits {
8686 #ifndef LAST_OTHER_INST
8787 #define LAST_OTHER_INST(num)
8888 #endif
89
9089
9190 // Terminator Instructions - These instructions are used to terminate a basic
9291 // block of the program. Every basic block must end with one of these
157157 static inline bool classof(const Value *V) {
158158 return isa(V) && classof(cast(V));
159159 }
160
160161 private:
161162 // Shadow Instruction::setInstructionSubclassData with a private forwarding
162163 // method so that subclasses cannot accidentally use it.
165166 }
166167 };
167168
168
169169 //===----------------------------------------------------------------------===//
170170 // LoadInst Class
171171 //===----------------------------------------------------------------------===//
175175 ///
176176 class LoadInst : public UnaryInstruction {
177177 void AssertOK();
178
178179 protected:
179180 // Note: Instruction needs to be a friend here to call cloneImpl.
180181 friend class Instruction;
289290 return getPointerOperand()->getType()->getPointerAddressSpace();
290291 }
291292
292
293293 // Methods for support type inquiry through isa, cast, and dyn_cast:
294294 static inline bool classof(const Instruction *I) {
295295 return I->getOpcode() == Instruction::Load;
297297 static inline bool classof(const Value *V) {
298298 return isa(V) && classof(cast(V));
299299 }
300
300301 private:
301302 // Shadow Instruction::setInstructionSubclassData with a private forwarding
302303 // method so that subclasses cannot accidentally use it.
305306 }
306307 };
307308
308
309309 //===----------------------------------------------------------------------===//
310310 // StoreInst Class
311311 //===----------------------------------------------------------------------===//
315315 class StoreInst : public Instruction {
316316 void *operator new(size_t, unsigned) = delete;
317317 void AssertOK();
318
318319 protected:
319320 // Note: Instruction needs to be a friend here to call cloneImpl.
320321 friend class Instruction;
343344 SynchronizationScope SynchScope,
344345 BasicBlock *InsertAtEnd);
345346
346
347347 /// isVolatile - Return true if this is a store to a volatile memory
348348 /// location.
349349 ///
421421 static inline bool classof(const Value *V) {
422422 return isa(V) && classof(cast(V));
423423 }
424
424425 private:
425426 // Shadow Instruction::setInstructionSubclassData with a private forwarding
426427 // method so that subclasses cannot accidentally use it.
444445 class FenceInst : public Instruction {
445446 void *operator new(size_t, unsigned) = delete;
446447 void Init(AtomicOrdering Ordering, SynchronizationScope SynchScope);
448
447449 protected:
448450 // Note: Instruction needs to be a friend here to call cloneImpl.
449451 friend class Instruction;
495497 static inline bool classof(const Value *V) {
496498 return isa(V) && classof(cast(V));
497499 }
500
498501 private:
499502 // Shadow Instruction::setInstructionSubclassData with a private forwarding
500503 // method so that subclasses cannot accidentally use it.
516519 void Init(Value *Ptr, Value *Cmp, Value *NewVal,
517520 AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering,
518521 SynchronizationScope SynchScope);
522
519523 protected:
520524 // Note: Instruction needs to be a friend here to call cloneImpl.
521525 friend class Instruction;
647651 static inline bool classof(const Value *V) {
648652 return isa(V) && classof(cast(V));
649653 }
654
650655 private:
651656 // Shadow Instruction::setInstructionSubclassData with a private forwarding
652657 // method so that subclasses cannot accidentally use it.
672677 ///
673678 class AtomicRMWInst : public Instruction {
674679 void *operator new(size_t, unsigned) = delete;
680
675681 protected:
676682 // Note: Instruction needs to be a friend here to call cloneImpl.
677683 friend class Instruction;
794800 static inline bool classof(const Value *V) {
795801 return isa(V) && classof(cast(V));
796802 }
803
797804 private:
798805 void Init(BinOp Operation, Value *Ptr, Value *Val,
799806 AtomicOrdering Ordering, SynchronizationScope SynchScope);
10771084 init(Ptr, IdxList, NameStr);
10781085 }
10791086
1080
10811087 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrInst, Value)
1082
10831088
10841089 //===----------------------------------------------------------------------===//
10851090 // ICmpInst Class
12251230 static inline bool classof(const Value *V) {
12261231 return isa(V) && classof(cast(V));
12271232 }
1228
12291233 };
12301234
12311235 //===----------------------------------------------------------------------===//
13801384 explicit CallInst(Value *F, const Twine &NameStr,
13811385 Instruction *InsertBefore);
13821386 CallInst(Value *F, const Twine &NameStr, BasicBlock *InsertAtEnd);
1387
13831388 protected:
13841389 // Note: Instruction needs to be a friend here to call cloneImpl.
13851390 friend class Instruction;
15681573 uint64_t getDereferenceableOrNullBytes(unsigned i) const {
15691574 return AttributeList.getDereferenceableOrNullBytes(i);
15701575 }
1571
1576
15721577 /// \brief Return true if the call should not be treated as a call to a
15731578 /// builtin.
15741579 bool isNoBuiltin() const {
17271732 init(Ty, Func, Args, NameStr);
17281733 }
17291734
1730
17311735 // Note: if you get compile errors about private methods then
17321736 // please update your code to use the high-level operand
17331737 // interfaces. See line 943 above.
17611765 init(C, S1, S2);
17621766 setName(NameStr);
17631767 }
1768
17641769 protected:
17651770 // Note: Instruction needs to be a friend here to call cloneImpl.
17661771 friend class Instruction;
18611866 Instruction *InsertBefore = nullptr);
18621867 ExtractElementInst(Value *Vec, Value *Idx, const Twine &NameStr,
18631868 BasicBlock *InsertAtEnd);
1869
18641870 protected:
18651871 // Note: Instruction needs to be a friend here to call cloneImpl.
18661872 friend class Instruction;
18901896 VectorType *getVectorOperandType() const {
18911897 return cast(getVectorOperand()->getType());
18921898 }
1893
18941899
18951900 /// Transparently provide more efficient getOperand methods.
18961901 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
20362041 getShuffleMask(Mask);
20372042 return Mask;
20382043 }
2039
20402044
20412045 // Methods for support type inquiry through isa, cast, and dyn_cast:
20422046 static inline bool classof(const Instruction *I) {
21622166 ExtractValue, Agg, InsertAtEnd) {
21632167 init(Idxs, NameStr);
21642168 }
2165
21662169
21672170 //===----------------------------------------------------------------------===//
21682171 // InsertValueInst Class
23362339 setName(NameStr);
23372340 allocHungoffUses(ReservedSpace);
23382341 }
2342
23392343 protected:
23402344 // allocHungoffUses - this is more complicated than the generic
23412345 // User::allocHungoffUses, because we have to allocate Uses for the incoming
24962500 static inline bool classof(const Value *V) {
24972501 return isa(V) && classof(cast(V));
24982502 }
2499 private:
2503
2504 private:
25002505 void growOperands();
25012506 };
25022507
25232528 /// the number actually in use.
25242529 unsigned ReservedSpace;
25252530 LandingPadInst(const LandingPadInst &LP);
2531
25262532 public:
25272533 enum ClauseType { Catch, Filter };
2534
25282535 private:
25292536 void *operator new(size_t, unsigned) = delete;
25302537 // Allocate space for exactly zero operands.
26352642 Instruction *InsertBefore = nullptr);
26362643 ReturnInst(LLVMContext &C, Value *retVal, BasicBlock *InsertAtEnd);
26372644 explicit ReturnInst(LLVMContext &C, BasicBlock *InsertAtEnd);
2645
26382646 protected:
26392647 // Note: Instruction needs to be a friend here to call cloneImpl.
26402648 friend class Instruction;
26712679 static inline bool classof(const Value *V) {
26722680 return isa(V) && classof(cast(V));
26732681 }
2674 private:
2682
2683 private:
26752684 BasicBlock *getSuccessorV(unsigned idx) const override;
26762685 unsigned getNumSuccessorsV() const override;
26772686 void setSuccessorV(unsigned idx, BasicBlock *B) override;
27102719 BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd);
27112720 BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
27122721 BasicBlock *InsertAtEnd);
2722
27132723 protected:
27142724 // Note: Instruction needs to be a friend here to call cloneImpl.
27152725 friend class Instruction;
27742784 static inline bool classof(const Value *V) {
27752785 return isa(V) && classof(cast(V));
27762786 }
2787
27772788 private:
27782789 BasicBlock *getSuccessorV(unsigned idx) const override;
27792790 unsigned getNumSuccessorsV() const override;
28202831 /// constructor also autoinserts at the end of the specified BasicBlock.
28212832 SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
28222833 BasicBlock *InsertAtEnd);
2834
28232835 protected:
28242836 // Note: Instruction needs to be a friend here to call cloneImpl.
28252837 friend class Instruction;
28262838 SwitchInst *cloneImpl() const;
28272839
28282840 public:
2829
28302841 // -2
28312842 static const unsigned DefaultPseudoIndex = static_cast(~0L-1);
28322843
28332844 template
28342845 class CaseIteratorT {
28352846 protected:
2836
28372847 SwitchInstTy *SI;
28382848 unsigned Index;
28392849
28402850 public:
2841
28422851 typedef CaseIteratorT Self;
28432852
28442853 /// Initializes case iterator for given SwitchInst and for given
30823091 static inline bool classof(const Value *V) {
30833092 return isa(V) && classof(cast(V));
30843093 }
3094
30853095 private:
30863096 BasicBlock *getSuccessorV(unsigned idx) const override;
30873097 unsigned getNumSuccessorsV() const override;
30933103 };
30943104
30953105 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SwitchInst, Value)
3096
30973106
30983107 //===----------------------------------------------------------------------===//
30993108 // IndirectBrInst Class
31273136 /// here to make memory allocation more efficient. This constructor also
31283137 /// autoinserts at the end of the specified BasicBlock.
31293138 IndirectBrInst(Value *Address, unsigned NumDests, BasicBlock *InsertAtEnd);
3139
31303140 protected:
31313141 // Note: Instruction needs to be a friend here to call cloneImpl.
31323142 friend class Instruction;
31503160 const Value *getAddress() const { return getOperand(0); }
31513161 void setAddress(Value *V) { setOperand(0, V); }
31523162
3153
31543163 /// getNumDestinations - return the number of possible destinations in this
31553164 /// indirectbr instruction.
31563165 unsigned getNumDestinations() const { return getNumOperands()-1; }
31823191 static inline bool classof(const Value *V) {
31833192 return isa(V) && classof(cast(V));
31843193 }
3194
31853195 private:
31863196 BasicBlock *getSuccessorV(unsigned idx) const override;
31873197 unsigned getNumSuccessorsV() const override;
31933203 };
31943204
31953205 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(IndirectBrInst, Value)
3196
31973206
31983207 //===----------------------------------------------------------------------===//
31993208 // InvokeInst Class
32373246 inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
32383247 ArrayRef Args, unsigned Values,
32393248 const Twine &NameStr, BasicBlock *InsertAtEnd);
3249
32403250 protected:
32413251 // Note: Instruction needs to be a friend here to call cloneImpl.
32423252 friend class Instruction;
33633373 uint64_t getDereferenceableBytes(unsigned i) const {
33643374 return AttributeList.getDereferenceableBytes(i);
33653375 }
3366
3376
33673377 /// \brief Extract the number of dereferenceable_or_null bytes for a call or
33683378 /// parameter (0=unknown).
33693379 uint64_t getDereferenceableOrNullBytes(unsigned i) const {
35563566
35573567 explicit ResumeInst(Value *Exn, Instruction *InsertBefore=nullptr);
35583568 ResumeInst(Value *Exn, BasicBlock *InsertAtEnd);
3569
35593570 protected:
35603571 // Note: Instruction needs to be a friend here to call cloneImpl.
35613572 friend class Instruction;
35843595 static inline bool classof(const Value *V) {
35853596 return isa(V) && classof(cast(V));
35863597 }
3598
35873599 private:
35883600 BasicBlock *getSuccessorV(unsigned idx) const override;
35893601 unsigned getNumSuccessorsV() const override;
42084220 ///
42094221 class UnreachableInst : public TerminatorInst {
42104222 void *operator new(size_t, unsigned) = delete;
4223
42114224 protected:
42124225 // Note: Instruction needs to be a friend here to call cloneImpl.
42134226 friend class Instruction;
42304243 static inline bool classof(const Value *V) {
42314244 return isa(V) && classof(cast(V));
42324245 }
4246
42334247 private:
42344248 BasicBlock *getSuccessorV(unsigned idx) const override;
42354249 unsigned getNumSuccessorsV() const override;
117117 Pass *P;
118118 Value *V;
119119 Module *M;
120
120121 public:
121122 explicit PassManagerPrettyStackEntry(Pass *p)
122123 : P(p), V(nullptr), M(nullptr) {} // When P is releaseMemory'd.
128129 /// print - Emit information about this stack frame to OS.
129130 void print(raw_ostream &OS) const override;
130131 };
131
132132
133133 //===----------------------------------------------------------------------===//
134134 // PMStack
157157 std::vector S;
158158 };
159159
160
161160 //===----------------------------------------------------------------------===//
162161 // PMTopLevelManager
163162 //
227226 PMStack activeStack;
228227
229228 protected:
230
231229 /// Collection of pass managers
232230 SmallVector PassManagers;
233231
234232 private:
235
236233 /// Collection of pass managers that are not directly maintained
237234 /// by this pass manager
238235 SmallVector IndirectPassManagers;
261258 mutable DenseMap AnalysisPassInfos;
262259 };
263260
264
265
266261 //===----------------------------------------------------------------------===//
267262 // PMDataManager
268263
270265 /// used by pass managers.
271266 class PMDataManager {
272267 public:
273
274268 explicit PMDataManager() : TPM(nullptr), Depth(0) {
275269 initializeAnalysisInfo();
276270 }
317311 // Return true if P preserves high level analysis used by other
318312 // passes that are managed by this manager.
319313 bool preserveHigherLevelAnalysis(Pass *P);
320
321314
322315 /// Populate UsedPasses with analysis pass that are used or required by pass
323316 /// P and are available. Populate ReqPassNotAvailable with analysis pass that
374367 }
375368
376369 protected:
377
378370 // Top level manager.
379371 PMTopLevelManager *TPM;
380372
441433 /// finalization tasks
442434 ///
443435 using ModulePass::doFinalization;
444
436
445437 /// doFinalization - Run all of the finalizers for the function passes.
446438 ///
447439 bool doFinalization(Module &M) override;
473465 };
474466
475467 Timer *getPassTimer(Pass *);
476
477468 }
478469
479470 #endif
9999 static void noteHead(NamedMDNode*, NamedMDNode*) {}
100100 void addNodeToList(NamedMDNode *) {}
101101 void removeNodeFromList(NamedMDNode *) {}
102
102103 private:
103104 mutable ilist_node Sentinel;
104105 };
653654
654655 /// Dump the module to stderr (for debugging).
655656 void dump() const;
656
657
657658 /// This function causes all the subinstructions to "let go" of all references
658659 /// that they are maintaining. This allows one to 'delete' a whole class at
659660 /// a time, even though there may be circular references... first all
700701 inline Module *unwrap(LLVMModuleProviderRef MP) {
701702 return reinterpret_cast(MP);
702703 }
703
704
704705 } // End llvm namespace
705706
706707 #endif
3939 template
4040 class SymbolTableListTraits : public ilist_default_traits {
4141 typedef ilist_traits TraitsClass;
42
4243 public:
4344 SymbolTableListTraits() {}
4445
131131
132132 /// isFloatTy - Return true if this is 'float', a 32-bit IEEE fp type.
133133 bool isFloatTy() const { return getTypeID() == FloatTyID; }
134
134
135135 /// isDoubleTy - Return true if this is 'double', a 64-bit IEEE fp type.
136136 bool isDoubleTy() const { return getTypeID() == DoubleTyID; }
137137
171171 /// isFPOrFPVectorTy - Return true if this is a FP type or a vector of FP.
172172 ///
173173 bool isFPOrFPVectorTy() const { return getScalarType()->isFloatingPointTy(); }
174
174
175175 /// isLabelTy - Return true if this is 'label'.
176176 bool isLabelTy() const { return getTypeID() == LabelTyID; }
177177
192192 /// integer types.
193193 ///
194194 bool isIntOrIntVectorTy() const { return getScalarType()->isIntegerTy(); }
195
195
196196 /// isFunctionTy - True if this is an instance of FunctionType.
197197 ///
198198 bool isFunctionTy() const { return getTypeID() == FunctionTyID; }
213213 /// pointer types.
214214 ///
215215 bool isPtrOrPtrVectorTy() const { return getScalarType()->isPointerTy(); }
216
216
217217 /// isVectorTy - True if this is an instance of VectorType.
218218 ///
219219 bool isVectorTy() const { return getTypeID() == VectorTyID; }
336336 // example) is shorthand for cast(Ty)->getNumElements(). This is
337337 // only intended to cover the core methods that are frequently used, helper
338338 // methods should not be added here.
339
339
340340 unsigned getIntegerBitWidth() const;
341341
342342 Type *getFunctionParamType(unsigned i) const;
343343 unsigned getFunctionNumParams() const;
344344 bool isFunctionVarArg() const;
345
345
346346 StringRef getStructName() const;
347347 unsigned getStructNumElements() const;
348348 Type *getStructElementType(unsigned N) const;
349
349
350350 Type *getSequentialElementType() const;
351
351
352352 uint64_t getArrayNumElements() const;
353353 Type *getArrayElementType() const { return getSequentialElementType(); }
354354
359359
360360 /// \brief Get the address space of this pointer or pointer vector type.
361361 unsigned getPointerAddressSpace() const;
362
362
363363 //===--------------------------------------------------------------------===//
364364 // Static members exported by the Type class itself. Useful for getting
365365 // instances of Type.
389389 static IntegerType *getInt32Ty(LLVMContext &C);
390390 static IntegerType *getInt64Ty(LLVMContext &C);
391391 static IntegerType *getInt128Ty(LLVMContext &C);
392
392
393393 //===--------------------------------------------------------------------===//
394394 // Convenience methods for getting pointer types with one of the above builtin
395395 // types as pointee.
432432 }
433433 };
434434
435
436435 //===----------------------------------------------------------------------===//
437436 // Provide specializations of GraphTraits to be able to treat a type as a
438437 // graph of sub types.
475474 inline LLVMTypeRef *wrap(Type **Tys) {
476475 return reinterpret_cast(const_cast(Tys));
477476 }
478
477
479478 } // End llvm namespace
480479
481480 #endif
5454 /// @name Constructors
5555 /// @{
5656 public:
57
5857 ValueSymbolTable() : vmap(0), LastUnique(0) {}
5958 ~ValueSymbolTable();
6059
6261 /// @name Accessors
6362 /// @{
6463 public:
65
6664 /// This method finds the value with the given \p Name in the
6765 /// the symbol table.
6866 /// @returns the value associated with the \p Name
106104 /// If the inserted name conflicts, this renames the value.
107105 /// @brief Add a named value to the symbol table
108106 void reinsertValue(Value *V);
109
107
110108 /// createValueName - This method attempts to create a value name and insert
111109 /// it into the symbol table with the specified name. If it conflicts, it
112110 /// auto-renames the name and returns that instead.
113111 ValueName *createValueName(StringRef Name, Value *V);
114
112
115113 /// This method removes a value from the symbol table. It leaves the
116114 /// ValueName attached to the value, but it is no longer inserted in the
117115 /// symtab.
16431643 FirstOp = false;
16441644 }
16451645
1646
16471646 for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) {
16481647 const MachineOperand &MO = getOperand(i);
16491648
23042304 return atoi(ConstraintCode.c_str());
23052305 }
23062306
2307
23082307 /// ParseConstraints - Split up the constraint string from the inline
23092308 /// assembly value into the specific constraints and their prefixes,
23102309 /// and also tie in the associated operand values.
24892488 " incompatible type!");
24902489 }
24912490 }
2492
24932491 }
24942492 }
24952493
24962494 return ConstraintOperands;
24972495 }
2498
24992496
25002497 /// getConstraintGenerality - Return an integer indicating how general CT
25012498 /// is.
15351535 SrcRegMap[RegA] = RegB;
15361536 }
15371537
1538
15391538 if (AllUsesCopied) {
15401539 if (!IsEarlyClobber) {
15411540 // Replace other (un-tied) uses of regB with LastCopiedReg.
402402 EHSectionFlags |= ELF::SHF_WRITE;
403403 }
404404
405
406405 // ELF
407406 BSSSection = Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
408407 ELF::SHF_WRITE | ELF::SHF_ALLOC);
7676 if (const MCConstantExpr *C =
7777 dyn_cast(S.getVariableValue()))
7878 return C->getValue();
79
8079
8180 MCValue Target;
8281 if (!S.getVariableValue()->evaluateAsRelocatable(Target, &Layout, nullptr))
744743 ++NumLoadCommands;
745744 LoadCommandsSize += ComputeLinkerOptionsLoadCommandSize(Option, is64Bit());
746745 }
747
746
748747 // Compute the total size of the section data, as well as its file size and vm
749748 // size.
750749 uint64_t SectionDataStart = (is64Bit() ? sizeof(MachO::mach_header_64) :
13841384 iterator_range MachOObjectFile::exports() const {
13851385 return exports(getDyldInfoExportsTrie());
13861386 }
1387
13881387
13891388 MachORebaseEntry::MachORebaseEntry(ArrayRef Bytes, bool is64Bit)
13901389 : Opcodes(Bytes), Ptr(Bytes.begin()), SegmentOffset(0), SegmentIndex(0),
17611760 return Result;
17621761 }
17631762
1764
17651763 uint32_t MachOBindEntry::segmentIndex() const { return SegmentIndex; }
17661764
17671765 uint64_t MachOBindEntry::segmentOffset() const { return SegmentOffset; }
23072305 return EC;
23082306 return std::move(Ret);
23092307 }
2310
161161 }
162162
163163 static bool classof(const AArch64MCExpr *) { return true; }
164
165164 };
166165 } // end namespace llvm
167166
498498 header.wavefront_sgpr_count = KernelInfo.NumSGPR;
499499 header.workitem_vgpr_count = KernelInfo.NumVGPR;
500500
501
502501 AMDGPUTargetStreamer *TS =
503502 static_cast(OutStreamer->getTargetStreamer());
504503 TS->EmitAMDKernelCodeT(header);
3939 // Subtarget - Keep a pointer to the AMDGPU Subtarget around so that we can
4040 // make the right decision when generating code for different targets.
4141 const AMDGPUSubtarget *Subtarget;
42
4243 public:
4344 AMDGPUDAGToDAGISel(TargetMachine &TM);
4445 virtual ~AMDGPUDAGToDAGISel();
584585
585586 return getS_BFE(Signed ? AMDGPU::S_BFE_I32 : AMDGPU::S_BFE_U32, SDLoc(N),
586587 N->getOperand(0), OffsetVal, WidthVal);
587
588588 }
589589 case AMDGPUISD::DIV_SCALE: {
590590 return SelectDIV_SCALE(N);
609609
610610 return SelectCode(N);
611611 }
612
613612
614613 bool AMDGPUDAGToDAGISel::checkType(const Value *Ptr, unsigned AS) {
615614 assert(AS != 0 && "Use checkPrivateAddress instead.");
10811080 VAddr = CurDAG->getTargetConstant(0, DL, MVT::i32);
10821081 Ptr = Addr;
10831082 Offset = CurDAG->getTargetConstant(0, DL, MVT::i16);
1084
10851083 }
10861084
10871085 bool AMDGPUDAGToDAGISel::SelectMUBUFAddr64(SDValue Addr, SDValue &SRsrc,
13661364 CurDAG->getTargetConstant(AMDGPU::sub0, DL, MVT::i32));
13671365 }
13681366
1369
13701367 if (DestSize > SrcSize) {
13711368 assert(SrcSize == 32 && DestSize == 64);
13721369
3636 const MCRegisterInfo &MRI;
3737
3838 public:
39
4039 R600MCCodeEmitter(const MCInstrInfo &mcii, const MCRegisterInfo &mri)
4140 : MCII(mcii), MRI(mri) { }
4241
4948 uint64_t getMachineOpValue(const MCInst &MI, const MCOperand &MO,
5049 SmallVectorImpl &Fixups,
5150 const MCSubtargetInfo &STI) const override;
51
5252 private:
53
5453 void EmitByte(unsigned int byte, raw_ostream &OS) const;
5554
5655 void Emit(uint32_t value, raw_ostream &OS) const;
5857
5958 unsigned getHWRegChan(unsigned reg) const;
6059 unsigned getHWReg(unsigned regNo) const;
61
6260 };
6361
6462 } // End anonymous namespace
1010 /// \brief SI implementation of the TargetRegisterInfo class.
1111 //
1212 //===----------------------------------------------------------------------===//
13
1413
1514 #include "SIRegisterInfo.h"
1615 #include "SIInstrInfo.h"
231231 }
232232 }
233233
234
235234 // Adjust FP so it point to the stack slot that contains the previous FP.
236235 if (HasFP) {
237236 FramePtrOffsetInBlock += MFI->getObjectOffset(FramePtrSpillFI)
157157 return RegName + 1;
158158 case 'c': if (RegName[1] == 'r') return RegName + 2;
159159 }
160
160
161161 return RegName;
162162 }
163163
165165 raw_ostream &O) {
166166 const DataLayout &DL = getDataLayout();
167167 const MachineOperand &MO = MI->getOperand(OpNo);
168
168
169169 switch (MO.getType()) {
170170 case MachineOperand::MO_Register: {
171171 const char *RegName = PPCInstPrinter::getRegisterName(MO.getReg());
314314 O << ")";
315315 return false;
316316 }
317
318317
319318 /// lookUpOrCreateTOCEntry -- Given a symbol, look up whether a TOC entry
320319 /// exists for it. If not, create one. Then return a symbol that references
402401 .addReg(PPC::X1));
403402 ++EncodedBytes;
404403
405
406404 // If we're on ELFv1, then we need to load the actual function pointer
407405 // from the function descriptor.
408406 if (!Subtarget->isELFv2ABI()) {
499497 bool isDarwin = TM.getTargetTriple().isOSDarwin();
500498 const Module *M = MF->getFunction()->getParent();
501499 PICLevel::Level PL = M->getPICLevel();
502
500
503501 // Lower multi-instruction pseudo operations.
504502 switch (MI->getOpcode()) {
505503 default: break;
537535 // bl L1$pb
538536 // L1$pb:
539537 MCSymbol *PICBase = MF->getPICBaseSymbol();
540
538
541539 // Emit the 'bl'.
542540 EmitToStreamer(*OutStreamer,
543541 MCInstBuilder(PPC::BL)
655653 EmitToStreamer(*OutStreamer, TmpInst);
656654 return;
657655 }
658
656
659657 case PPC::ADDIStocHA: {
660658 // Transform %Xd = ADDIStocHA %X2,
661659 LowerPPCMachineInstrToMCInst(MI, TmpInst, *this, isDarwin);
11291127 OutStreamer->EmitIntValue(0, 8 /* size */);
11301128 OutStreamer->SwitchSection(Current.first, Current.second);
11311129 }
1132
11331130
11341131 bool PPCLinuxAsmPrinter::doFinalization(Module &M) {
11351132 const DataLayout &DL = getDataLayout();
13531350 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
13541351 OutStreamer->SwitchSection(StubSection);
13551352 EmitAlignment(4);
1356
1353
13571354 MCSymbol *Stub = Stubs[i].first;
13581355 MCSymbol *RawSym = Stubs[i].second.getPointer();
13591356 MCSymbol *LazyPtr = GetLazyPtr(Stub, OutContext);
13601357 MCSymbol *AnonSymbol = GetAnonSym(Stub, OutContext);
1361
1358
13621359 OutStreamer->EmitLabel(Stub);
13631360 OutStreamer->EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol);
13641361
14631460 OutStreamer->EmitSymbolValue(DyldStubBindingHelper, 4);
14641461 }
14651462 }
1466
1463
14671464 OutStreamer->AddBlankLine();
14681465 }
1469
14701466
14711467 bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
14721468 bool isPPC64 = getDataLayout().getPointerSizeInBits() == 64;
14981494
14991495 // Output stubs for dynamically-linked functions.
15001496 Stubs = MMIMacho.GetGVStubList();
1501
1497
15021498 // Output macho stubs for external and common global variables.
15031499 if (!Stubs.empty()) {
15041500 // Switch with ".non_lazy_symbol_pointer" directive.
15051501 OutStreamer->SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
15061502 EmitAlignment(isPPC64 ? 3 : 2);
1507
1503
15081504 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
15091505 // L_foo$stub:
15101506 OutStreamer->EmitLabel(Stubs[i].first);
15351531 if (!Stubs.empty()) {
15361532 OutStreamer->SwitchSection(getObjFileLowering().getDataSection());
15371533 EmitAlignment(isPPC64 ? 3 : 2);
1538
1534
15391535 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
15401536 // L_foo$stub:
15411537 OutStreamer->EmitLabel(Stubs[i].first);
360360 true);
361361 if (VTy == MVT::Other)
362362 return true;
363
363
364364 if (TLI->isOperationLegalOrCustom(Opcode, VTy))
365365 continue;
366366 else if (VTy.isVector() &&
684684 return false;
685685 }
686686 #endif // NDEBUG
687
522522 setOperationAction(ISD::MUL, MVT::v4i32, Legal);
523523 else
524524 setOperationAction(ISD::MUL, MVT::v4i32, Custom);
525
525
526526 setOperationAction(ISD::MUL, MVT::v8i16, Custom);
527527 setOperationAction(ISD::MUL, MVT::v16i8, Custom);
528528
16361636 return isIntS16Immediate(Op.getNode(), Imm);
16371637 }
16381638
1639
16401639 /// SelectAddressRegReg - Given the specified addressed, check to see if it
16411640 /// can be represented as an indexed [r+r] operation. Returns false if it
16421641 /// can be more efficiently represented with [r+imm].
24892488 // * are stored
24902489 // */
24912490 // } va_list[1];
2492
24932491
24942492 SDValue ArgGPR = DAG.getConstant(FuncInfo->getVarArgsNumGPR(), dl, MVT::i32);
24952493 SDValue ArgFPR = DAG.getConstant(FuncInfo->getVarArgsNumFPR(), dl, MVT::i32);
38903888
38913889 TailCallArgumentInfo() : FrameIdx(0) {}
38923890 };
3893
38943891 }
38953892
38963893 /// StoreTailCallArgumentsToStackSlot - Stores arguments to their stack slot.
59985995 SDNodeFlags Flags;
59995996 Flags.setNoInfs(true);
60005997 Flags.setNoNaNs(true);
6001
5998
60025999 ISD::CondCode CC = cast(Op.getOperand(4))->get();
60036000
60046001 EVT ResVT = Op.getValueType();
63076304 // into 0 (false) and 1 (true), add 1 and then divide by 2 (multiply by 0.5).
63086305 // This can be done with an fma and the 0.5 constant: (V+1.0)*0.5 = 0.5*V+0.5
63096306 Value = DAG.getNode(PPCISD::QBFLT, dl, MVT::v4f64, Value);
6310
6307
63116308 SDValue FPHalfs = DAG.getConstantFP(0.5, dl, MVT::f64);
63126309 FPHalfs = DAG.getNode(ISD::BUILD_VECTOR, dl, MVT::v4f64, FPHalfs, FPHalfs,
63136310 FPHalfs, FPHalfs);
67566753 DAG.getConstant(IID, dl, MVT::i32), Op0, Op1, Op2);
67576754 }
67586755
6759
67606756 /// BuildVSLDOI - Return a VECTOR_SHUFFLE that is a vsldoi of the specified
67616757 /// amount. The result has the specified value type.
67626758 static SDValue BuildVSLDOI(SDValue LHS, SDValue RHS, unsigned Amt,
69366932 (32-SplatBitSize));
69376933 if (SextVal >= -16 && SextVal <= 15)
69386934 return BuildSplatI(SextVal, SplatSize, Op.getValueType(), DAG, dl);
6939
69406935
69416936 // Two instruction sequences.
69426937
80368031 return;
80378032 }
80388033 }
8039
80408034
80418035 //===----------------------------------------------------------------------===//
80428036 // Other Lowering Code
93769370 for (SmallSet::iterator I = LoadRoots.begin(),
93779371 IE = LoadRoots.end(); I != IE; ++I) {
93789372 Queue.push_back(*I);
9379
9373
93809374 while (!Queue.empty()) {
93819375 SDNode *LoadRoot = Queue.pop_back_val();
93829376 if (!Visited.insert(LoadRoot).second)
1056210556 case ISD::BRCOND: {
1056310557 SDValue Cond = N->getOperand(1);
1056410558 SDValue Target = N->getOperand(2);
10565
10559
1056610560 if (Cond.getOpcode() == ISD::INTRINSIC_W_CHAIN &&
1056710561 cast(Cond.getOperand(1))->getZExtValue() ==
1056810562 Intrinsic::ppc_is_decremented_ctr_nonzero) {
1094210936
1094310937 return R;
1094410938 }
10945
1094610939
1094710940 /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
1094810941 /// vector. If it is invalid, don't add anything to Ops.
199199 Reserved.set(PPC::R2); // System-reserved register
200200 Reserved.set(PPC::R13); // Small Data Area pointer register
201201 }
202
202
203203 // On PPC64, r13 is the thread pointer. Never allocate this register.
204204 if (TM.isPPC64()) {
205205 Reserved.set(PPC::R13);
336336 unsigned maxCallFrameSize = MFI->getMaxCallFrameSize();
337337 // Get the total frame size.
338338 unsigned FrameSize = MFI->getStackSize();
339
339
340340 // Get stack alignments.
341341 const PPCFrameLowering *TFI = getFrameLowering(MF);
342342 unsigned TargetAlign = TFI->getStackAlignment();
353353 const TargetRegisterClass *G8RC = &PPC::G8RCRegClass;
354354 const TargetRegisterClass *GPRC = &PPC::GPRCRegClass;
355355 unsigned Reg = MF.getRegInfo().createVirtualRegister(LP64 ? G8RC : GPRC);
356
356
357357 if (MaxAlign < TargetAlign && isInt<16>(FrameSize)) {
358358 BuildMI(MBB, II, dl, TII.get(PPC::ADDI), Reg)
359359 .addReg(PPC::R31)
424424 .addReg(PPC::R1)
425425 .addImm(maxCallFrameSize);
426426 }
427
427
428428 // Discard the DYNALLOC instruction.
429429 MBB.erase(II);
430430 }
753753 int FPSI = FI->getFramePointerSaveIndex();
754754 // Get the instruction opcode.
755755 unsigned OpC = MI.getOpcode();
756
756
757757 // Special case for dynamic alloca.
758758 if (FPSI && FrameIndex == FPSI &&
759759 (OpC == PPC::DYNALLOC || OpC == PPC::DYNALLOC8)) {
5353 return Reg;
5454 }
5555
56
5756 class PPCRegisterInfo : public PPCGenRegisterInfo {
5857 DenseMap ImmToIdxMap;
5958 const PPCTargetMachine &TM;
59
6060 public:
6161 PPCRegisterInfo(const PPCTargetMachine &TM);
62
62
6363 /// getPointerRegClass - Return the register class to use to hold pointers.
6464 /// This is used for addressing modes.
6565 const TargetRegisterClass *
6060 const MCInstrInfo &MII;
6161 ParseInstructionInfo *InstInfo;
6262 std::unique_ptr Instrumentation;
63
6364 private:
6465 SMLoc consumeToken() {
6566 MCAsmParser &Parser = getParser();
268269 bool StopOnLBrac, AddImmPrefix;
269270 InfixCalculator IC;
270271 InlineAsmIdentifierInfo Info;
272
271273 public:
272274 IntelExprStateMachine(int64_t imm, bool stoponlbrac, bool addimmprefix) :
273275 State(IES_PLUS), PrevState(IES_ERROR), BaseReg(0), IndexReg(0), TmpReg(0),
774776 unsigned FB = ComputeAvailableFeatures(
775777 STI.ToggleFeature(OldMode.flip(mode)));
776778 setAvailableFeatures(FB);
777
779
778780 assert(FeatureBitset({mode}) == (STI.getFeatureBits() & AllModes));
779781 }
780782
21842186 Name == "repne" || Name == "repnz" ||
21852187 Name == "rex64" || Name == "data16";
21862188
2187
21882189 // This does the actual operand parsing. Don't parse any more if we have a
21892190 // prefix juxtaposed with an operation like "lock incl 4(%rax)", because we
21902191 // just want to parse the "lock" as the first instruction and the "incl" as
12781278 if (Subtarget->hasInt256())
12791279 setOperationAction(ISD::VSELECT, MVT::v32i8, Legal);
12801280
1281
12821281 // Promote v32i8, v16i16, v8i32 select, and, or, xor to v4i64.
12831282 for (int i = MVT::v32i8; i != MVT::v4i64; ++i) {
12841283 MVT VT = (MVT::SimpleValueType)i;
17151714 setOperationAction(ISD::SMULO, VT, Custom);
17161715 setOperationAction(ISD::UMULO, VT, Custom);
17171716 }
1718
17191717
17201718 if (!Subtarget->is64Bit()) {
17211719 // These libcalls are not available in 32-bit.
64706468 // 512-bit vector may contain 2 256-bit vectors or 4 128-bit vectors
64716469 return LowerAVXCONCAT_VECTORS(Op, DAG);
64726470 }
6473
64746471
64756472 //===----------------------------------------------------------------------===//
64766473 // Vector shuffle lowering
2485924856 ISD::NON_EXTLOAD);
2486024857 SDValue NewVec = DAG.getNode(X86ISD::VSEXT, dl, VT, WideLd);
2486124858 return DCI.CombineTo(N, NewVec, WideLd.getValue(1), true);
24862
2486324859 }
2486424860 /// PerformMSTORECombine - Resolve truncating stores
2486524861 static SDValue PerformMSTORECombine(SDNode *N, SelectionDAG &DAG,
226226 seen(I, unknownRange());
227227 break;
228228 }
229
229
230230 for (Value *O : I->operands()) {
231231 if (Instruction *OI = dyn_cast(O)) {
232232 // Unify def-use chains if they interfere.
399399 R.isFullSet() || R.isSignWrappedSet())
400400 continue;
401401 assert(ConvertedToTy && "Must have set the convertedtoty by this point!");
402
402
403403 // The number of bits required is the maximum of the upper and
404404 // lower limits, plus one so it can be signed.
405405 unsigned MinBW = std::max(R.getLower().getMinSignedBits(),