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,
53void InlineAsm::destroyConstant() {
72 AsmStr.
split(AsmStrs,
"\n\t", -1,
false);
81 unsigned multipleAlternativeCount = Str.count(
'|') + 1;
82 unsigned multipleAlternativeIndex = 0;
104 if (
I != E && *
I !=
'{')
106 }
else if (*
I ==
'=') {
109 }
else if (*
I ==
'!') {
119 if (
I == E)
return true;
122 bool DoneWithModifiers =
false;
123 while (!DoneWithModifiers) {
126 DoneWithModifiers =
true;
145 if (!DoneWithModifiers) {
147 if (
I == E)
return true;
156 if (ConstraintEnd == E)
return true;
157 pCodes->push_back(std::string(
StringRef(
I, ConstraintEnd + 1 -
I)));
159 }
else if (isdigit(
static_cast<unsigned char>(*
I))) {
162 while (
I != E && isdigit(
static_cast<unsigned char>(*
I)))
164 pCodes->push_back(std::string(
StringRef(NumStart,
I - NumStart)));
165 unsigned N = atoi(pCodes->back().c_str());
167 if (
N >= ConstraintsSoFar.size() || ConstraintsSoFar[
N].Type !=
isOutput||
174 if (multipleAlternativeIndex >=
178 ConstraintsSoFar[
N].multipleAlternatives[multipleAlternativeIndex];
187 ConstraintsSoFar.size())
190 ConstraintsSoFar[
N].MatchingInput = ConstraintsSoFar.size();
193 }
else if (*
I ==
'|') {
194 multipleAlternativeIndex++;
197 }
else if (*
I ==
'^') {
200 pCodes->push_back(std::string(
StringRef(
I + 1, 2)));
202 }
else if (*
I ==
'@') {
205 unsigned char C =
static_cast<unsigned char>(*I);
206 assert(isdigit(
C) &&
"Expected a digit!");
208 assert(
N > 0 &&
"Found a zero letter constraint!");
214 pCodes->push_back(std::string(
StringRef(
I, 1)));
225 if (index < multipleAlternatives.size()) {
226 currentAlternativeIndex = index;
228 multipleAlternatives[currentAlternativeIndex];
230 Codes = scInfo.
Codes;
240 E = Constraints.
end();
I != E; ) {
246 if (ConstraintEnd ==
I ||
252 Result.push_back(
Info);
280 if (Constraints.empty() && !ConstStr.
empty())
283 unsigned NumOutputs = 0, NumInputs = 0, NumClobbers = 0;
284 unsigned NumIndirect = 0, NumLabels = 0;
287 switch (Constraint.Type) {
289 if ((NumInputs-NumIndirect) != 0 || NumClobbers != 0 || NumLabels != 0)
291 "clobber or label constraint");
293 if (!Constraint.isIndirect) {
318 switch (NumOutputs) {
325 return makeStringError(
"inline asm with one output cannot return struct");
331 "number of return struct elements");
336 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...