31 InlineAsm::InlineAsm(
FunctionType *FTy,
const std::string &asmString,
32 const std::string &constraints,
bool hasSideEffects,
33 bool isAlignStack, AsmDialect asmDialect)
35 AsmString(asmString), Constraints(constraints), FTy(FTy),
36 HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
40 "Function type not legal for constraints!");
44 StringRef Constraints,
bool hasSideEffects,
47 isAlignStack, asmDialect);
52 void InlineAsm::destroyConstant() {
53 getType()->getContext().pImpl->InlineAsms.remove(
this);
67 unsigned multipleAlternativeCount = Str.
count(
'|') + 1;
68 unsigned multipleAlternativeIndex = 0;
72 isMultipleAlternative = multipleAlternativeCount > 1;
73 if (isMultipleAlternative) {
74 multipleAlternatives.resize(multipleAlternativeCount);
75 pCodes = &multipleAlternatives[0].Codes;
78 isEarlyClobber =
false;
80 isCommutative =
false;
82 currentAlternativeIndex = 0;
90 if (I !=
E && *I !=
'{')
92 }
else if (*I ==
'=') {
102 if (I ==
E)
return true;
105 bool DoneWithModifiers =
false;
106 while (!DoneWithModifiers) {
109 DoneWithModifiers =
true;
112 if (
Type != isOutput ||
115 isEarlyClobber =
true;
118 if (
Type == isClobber ||
121 isCommutative =
true;
128 if (!DoneWithModifiers) {
130 if (I ==
E)
return true;
139 if (ConstraintEnd ==
E)
return true;
140 pCodes->push_back(
StringRef(I, ConstraintEnd+1 - I));
142 }
else if (isdigit(static_cast<unsigned char>(*I))) {
145 while (I !=
E && isdigit(static_cast<unsigned char>(*I)))
147 pCodes->push_back(
StringRef(NumStart, I - NumStart));
148 unsigned N = atoi(pCodes->back().c_str());
150 if (N >= ConstraintsSoFar.size() || ConstraintsSoFar[
N].Type != isOutput||
156 if (isMultipleAlternative) {
157 if (multipleAlternativeIndex >=
158 ConstraintsSoFar[N].multipleAlternatives.size())
161 ConstraintsSoFar[
N].multipleAlternatives[multipleAlternativeIndex];
168 if (ConstraintsSoFar[N].hasMatchingInput() &&
169 (
size_t)ConstraintsSoFar[N].MatchingInput !=
170 ConstraintsSoFar.size())
173 ConstraintsSoFar[
N].MatchingInput = ConstraintsSoFar.size();
174 assert(ConstraintsSoFar[N].MatchingInput >= 0);
176 }
else if (*I ==
'|') {
177 multipleAlternativeIndex++;
178 pCodes = &multipleAlternatives[multipleAlternativeIndex].Codes;
180 }
else if (*I ==
'^') {
198 if (index < multipleAlternatives.size()) {
199 currentAlternativeIndex = index;
201 multipleAlternatives[currentAlternativeIndex];
203 Codes = scInfo.
Codes;
213 E = Constraints.
end();
I !=
E; ) {
219 if (ConstraintEnd ==
I ||
225 Result.push_back(Info);
250 if (Constraints.empty() && !ConstStr.
empty())
return false;
252 unsigned NumOutputs = 0, NumInputs = 0, NumClobbers = 0;
253 unsigned NumIndirect = 0;
255 for (
unsigned i = 0, e = Constraints.size(); i != e; ++i) {
256 switch (Constraints[i].
Type) {
258 if ((NumInputs-NumIndirect) != 0 || NumClobbers != 0)
260 if (!Constraints[i].isIndirect) {
267 if (NumClobbers)
return false;
276 switch (NumOutputs) {
This class represents lattice values for constants.
unsigned getNumElements() const
Random access to the elements.
bool Parse(StringRef Str, ConstraintInfoVector &ConstraintsSoFar)
Parse - Analyze the specified string (e.g.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
std::vector< std::string > ConstraintCodeVector
LLVM_NODISCARD size_t count(char C) const
Return the number of occurrences of C in the string.
Class to represent struct types.
ConstantUniqueMap< InlineAsm > InlineAsms
Class to represent function types.
ppc ctr loops PowerPC CTR Loops Verify
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
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...
Analysis containing CSE Info
Class to represent pointers.
bool isVoidTy() const
Return true if this is 'void'.
The instances of the Type class are immutable: once they are created, they are never changed...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
static wasm::ValType getType(const TargetRegisterClass *RC)
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
LLVMContextImpl *const pImpl
std::vector< ConstraintInfo > ConstraintInfoVector
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...
Type * getReturnType() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
FunctionType * getFunctionType() const
getFunctionType - InlineAsm's are always pointers to functions.
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isInput(const StringSet<> &Prefixes, StringRef Arg)
LLVM Value Representation.
int MatchingInput
MatchingInput - If this is not -1, this is an output constraint where an input constraint is required...
StringRef - Represent a constant reference to a string, i.e.
ConstraintInfoVector ParseConstraints() const
ParseConstraints - Parse the constraints of this inlineasm object, returning them the same way that P...
bool isStructTy() const
True if this is an instance of StructType.
void selectAlternative(unsigned index)
selectAlternative - Point this constraint to the alternative constraint indicated by the index...