24 InlineAsm::~InlineAsm() {
28 StringRef Constraints,
bool hasSideEffects,
31 isAlignStack, asmDialect);
36 InlineAsm::InlineAsm(
FunctionType *FTy,
const std::string &asmString,
37 const std::string &constraints,
bool hasSideEffects,
38 bool isAlignStack, AsmDialect asmDialect)
40 AsmString(asmString), Constraints(constraints), FTy(FTy),
41 HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
46 "Function type not legal for constraints!");
49 void InlineAsm::destroyConstant() {
61 MatchingInput(-1), isCommutative(
false),
62 isIndirect(
false), isMultipleAlternative(
false),
63 currentAlternativeIndex(0) {
72 unsigned multipleAlternativeCount = Str.
count(
'|') + 1;
73 unsigned multipleAlternativeIndex = 0;
77 isMultipleAlternative = multipleAlternativeCount > 1;
78 if (isMultipleAlternative) {
79 multipleAlternatives.resize(multipleAlternativeCount);
80 pCodes = &multipleAlternatives[0].Codes;
83 isEarlyClobber =
false;
85 isCommutative =
false;
87 currentAlternativeIndex = 0;
95 if (I !=
E && *I !=
'{')
97 }
else if (*I ==
'=') {
107 if (I ==
E)
return true;
110 bool DoneWithModifiers =
false;
111 while (!DoneWithModifiers) {
114 DoneWithModifiers =
true;
120 isEarlyClobber =
true;
126 isCommutative =
true;
133 if (!DoneWithModifiers) {
135 if (I ==
E)
return true;
144 if (ConstraintEnd ==
E)
return true;
145 pCodes->push_back(
StringRef(I, ConstraintEnd+1 - I));
147 }
else if (isdigit(static_cast<unsigned char>(*I))) {
150 while (I !=
E && isdigit(static_cast<unsigned char>(*I)))
152 pCodes->push_back(
StringRef(NumStart, I - NumStart));
153 unsigned N = atoi(pCodes->back().c_str());
155 if (N >= ConstraintsSoFar.size() || ConstraintsSoFar[
N].Type !=
isOutput||
161 if (isMultipleAlternative) {
162 if (multipleAlternativeIndex >=
163 ConstraintsSoFar[N].multipleAlternatives.size())
166 ConstraintsSoFar[
N].multipleAlternatives[multipleAlternativeIndex];
172 if (ConstraintsSoFar[N].hasMatchingInput() &&
173 (
size_t)ConstraintsSoFar[N].MatchingInput !=
174 ConstraintsSoFar.size())
177 ConstraintsSoFar[
N].MatchingInput = ConstraintsSoFar.size();
179 }
else if (*I ==
'|') {
180 multipleAlternativeIndex++;
181 pCodes = &multipleAlternatives[multipleAlternativeIndex].Codes;
183 }
else if (*I ==
'^') {
201 if (index < multipleAlternatives.size()) {
202 currentAlternativeIndex = index;
204 multipleAlternatives[currentAlternativeIndex];
206 Codes = scInfo.
Codes;
216 E = Constraints.
end();
I !=
E; ) {
222 if (ConstraintEnd ==
I ||
228 Result.push_back(Info);
253 if (Constraints.empty() && !ConstStr.
empty())
return false;
255 unsigned NumOutputs = 0, NumInputs = 0, NumClobbers = 0;
256 unsigned NumIndirect = 0;
258 for (
unsigned i = 0, e = Constraints.size();
i != e; ++
i) {
259 switch (Constraints[
i].
Type) {
261 if ((NumInputs-NumIndirect) != 0 || NumClobbers != 0)
263 if (!Constraints[
i].isIndirect) {
270 if (NumClobbers)
return false;
279 switch (NumOutputs) {
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
bool Parse(StringRef Str, ConstraintInfoVector &ConstraintsSoFar)
Parse - Analyze the specified string (e.g.
static bool isInput(const llvm::StringSet<> &Prefixes, StringRef Arg)
Class to represent struct types.
ConstraintInfoVector ParseConstraints() const
ParseConstraints - Parse the constraints of this inlineasm object, returning them the same way that P...
ConstantUniqueMap< InlineAsm > InlineAsms
Class to represent function types.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Function Alias Analysis false
static bool Verify(FunctionType *Ty, StringRef Constraints)
Verify - This static method can be used by the parser to check to see if the specified constraint str...
Class to represent pointers.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
The instances of the Type class are immutable: once they are created, they are never changed...
ConstraintInfo()
Default constructor.
PointerType * getType() const
getType - InlineAsm's are always pointers.
LLVM_NODISCARD size_t count(char C) const
Return the number of occurrences of C in the string.
LLVMContextImpl *const pImpl
signed char MatchingInput
MatchingInput - If this is not -1, this is an output constraint where an input constraint is required...
FunctionType * getFunctionType() const
getFunctionType - InlineAsm's are always pointers to functions.
std::vector< std::string > ConstraintCodeVector
ConstraintCodeVector Codes
Code - The constraint code, either the register name (in braces) or the constraint letter/number...
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
auto find(R &&Range, const T &Val) -> decltype(std::begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
bool isStructTy() const
True if this is an instance of StructType.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static InlineAsm * get(FunctionType *Ty, StringRef AsmString, StringRef Constraints, bool hasSideEffects, bool isAlignStack=false, AsmDialect asmDialect=AD_ATT)
InlineAsm::get - Return the specified uniqued inline asm string.
Type * getReturnType() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
StringRef - Represent a constant reference to a string, i.e.
unsigned getNumElements() const
Random access to the elements.
std::vector< ConstraintInfo > ConstraintInfoVector
bool isVoidTy() const
Return true if this is 'void'.
void selectAlternative(unsigned index)
selectAlternative - Point this constraint to the alternative constraint indicated by the index...