30InlineAsm::InlineAsm(
FunctionType *FTy,
const std::string &asmString,
31 const std::string &constraints,
bool hasSideEffects,
32 bool isAlignStack, AsmDialect asmDialect,
bool canThrow)
34 AsmString(asmString), Constraints(constraints), FTy(FTy),
35 HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
36 Dialect(asmDialect), CanThrow(
canThrow) {
44 StringRef Constraints,
bool hasSideEffects,
54void InlineAsm::destroyConstant() {
73 AsmStr.
split(AsmStrs,
"\n\t", -1,
false);
82 unsigned multipleAlternativeCount = Str.count(
'|') + 1;
83 unsigned multipleAlternativeIndex = 0;
105 if (
I != E && *
I !=
'{')
107 }
else if (*
I ==
'=') {
110 }
else if (*
I ==
'!') {
120 if (
I == E)
return true;
123 bool DoneWithModifiers =
false;
124 while (!DoneWithModifiers) {
127 DoneWithModifiers =
true;
146 if (!DoneWithModifiers) {
148 if (
I == E)
return true;
157 if (ConstraintEnd == E)
return true;
158 pCodes->push_back(std::string(
StringRef(
I, ConstraintEnd + 1 -
I)));
160 }
else if (isdigit(
static_cast<unsigned char>(*
I))) {
163 while (
I != E && isdigit(
static_cast<unsigned char>(*
I)))
165 pCodes->push_back(std::string(
StringRef(NumStart,
I - NumStart)));
166 unsigned N = atoi(pCodes->back().c_str());
168 if (
N >= ConstraintsSoFar.size() || ConstraintsSoFar[
N].Type !=
isOutput||
175 if (multipleAlternativeIndex >=
179 ConstraintsSoFar[
N].multipleAlternatives[multipleAlternativeIndex];
188 ConstraintsSoFar.size())
191 ConstraintsSoFar[
N].MatchingInput = ConstraintsSoFar.size();
194 }
else if (*
I ==
'|') {
195 multipleAlternativeIndex++;
198 }
else if (*
I ==
'^') {
201 pCodes->push_back(std::string(
StringRef(
I + 1, 2)));
203 }
else if (*
I ==
'@') {
206 unsigned char C =
static_cast<unsigned char>(*I);
207 assert(isdigit(
C) &&
"Expected a digit!");
209 assert(
N > 0 &&
"Found a zero letter constraint!");
215 pCodes->push_back(std::string(
StringRef(
I, 1)));
226 if (index < multipleAlternatives.size()) {
227 currentAlternativeIndex = index;
229 multipleAlternatives[currentAlternativeIndex];
231 Codes = scInfo.
Codes;
241 E = Constraints.
end();
I != E; ) {
247 if (ConstraintEnd ==
I ||
253 Result.push_back(
Info);
281 if (Constraints.empty() && !ConstStr.
empty())
284 unsigned NumOutputs = 0, NumInputs = 0, NumClobbers = 0;
285 unsigned NumIndirect = 0, NumLabels = 0;
288 switch (Constraint.Type) {
290 if ((NumInputs-NumIndirect) != 0 || NumClobbers != 0 || NumLabels != 0)
292 "clobber or label constraint");
294 if (!Constraint.isIndirect) {
319 switch (NumOutputs) {
326 return makeStringError(
"inline asm with one output cannot return struct");
332 "number of return struct elements");
337 return makeStringError(
"number of input constraints does not match number "
Analysis containing CSE Info
static Error makeStringError(const char *Msg)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool canThrow(const Value *V)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Class to represent function types.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Type * getReturnType() const
void collectAsmStrs(SmallVectorImpl< StringRef > &AsmStrs) const
static InlineAsm * get(FunctionType *Ty, StringRef AsmString, StringRef Constraints, bool hasSideEffects, bool isAlignStack=false, AsmDialect asmDialect=AD_ATT, bool canThrow=false)
InlineAsm::get - Return the specified uniqued inline asm string.
std::vector< ConstraintInfo > ConstraintInfoVector
bool isAlignStack() const
FunctionType * getFunctionType() const
getFunctionType - InlineAsm's are always pointers to functions.
bool hasSideEffects() const
ConstraintInfoVector ParseConstraints() const
ParseConstraints - Parse the constraints of this inlineasm object, returning them the same way that P...
std::vector< std::string > ConstraintCodeVector
static Error verify(FunctionType *Ty, StringRef Constraints)
This static method can be used by the parser to check to see if the specified constraint string is le...
PointerType * getType() const
getType - InlineAsm's are always pointers.
ConstantUniqueMap< InlineAsm > InlineAsms
LLVMContextImpl *const pImpl
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
constexpr bool empty() const
empty - Check if the string is empty.
Class to represent struct types.
unsigned getNumElements() const
Random access to the elements.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isStructTy() const
True if this is an instance of StructType.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
bool isVoidTy() const
Return true if this is 'void'.
LLVM Value Representation.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
bool isCommutative
isCommutative - This is set to true for a constraint that is commutative with the next operand.
int MatchingInput
MatchingInput - If this is not -1, this is an output constraint where an input constraint is required...
ConstraintCodeVector Codes
Code - The constraint code, either the register name (in braces) or the constraint letter/number.
unsigned currentAlternativeIndex
The currently selected alternative constraint index.
bool Parse(StringRef Str, ConstraintInfoVector &ConstraintsSoFar)
Parse - Analyze the specified string (e.g.
SubConstraintInfoVector multipleAlternatives
multipleAlternatives - If there are multiple alternative constraints, this array will contain them.
bool isIndirect
isIndirect - True if this operand is an indirect operand.
bool isEarlyClobber
isEarlyClobber - "&": output operand writes result before inputs are all read.
bool isMultipleAlternative
isMultipleAlternative - '|': has multiple-alternative constraints.
void selectAlternative(unsigned index)
selectAlternative - Point this constraint to the alternative constraint indicated by the index.
bool hasMatchingInput() const
hasMatchingInput - Return true if this is an output constraint that has a matching input constraint.
ConstraintCodeVector Codes
Code - The constraint code, either the register name (in braces) or the constraint letter/number.
int MatchingInput
MatchingInput - If this is not -1, this is an output constraint where an input constraint is required...