forked from OSchip/llvm-project
[RISCV] Add inline asm constraints I, J & K for RISC-V
This allows the constraints I, J & K to be used in inline asm for RISC-V, with the following semantics (equivalent to GCC): I: Any 12-bit signed immediate. J: Integer zero only. K: Any 5-bit unsigned immediate. See the GCC definitions here: https://gcc.gnu.org/onlinedocs/gccint/Machine-Constraints.html Differential Revision: https://reviews.llvm.org/D54091 llvm-svn: 363055
This commit is contained in:
parent
28a5cadb3a
commit
5665ef3dcc
|
@ -39,6 +39,26 @@ ArrayRef<TargetInfo::GCCRegAlias> RISCVTargetInfo::getGCCRegAliases() const {
|
|||
return llvm::makeArrayRef(GCCRegAliases);
|
||||
}
|
||||
|
||||
bool RISCVTargetInfo::validateAsmConstraint(
|
||||
const char *&Name, TargetInfo::ConstraintInfo &Info) const {
|
||||
switch (*Name) {
|
||||
default:
|
||||
return false;
|
||||
case 'I':
|
||||
// A 12-bit signed immediate.
|
||||
Info.setRequiresImmediate(-2048, 2047);
|
||||
return true;
|
||||
case 'J':
|
||||
// Integer zero.
|
||||
Info.setRequiresImmediate(0);
|
||||
return true;
|
||||
case 'K':
|
||||
// A 5-bit unsigned immediate for CSR access instructions.
|
||||
Info.setRequiresImmediate(0, 31);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
|
||||
MacroBuilder &Builder) const {
|
||||
Builder.defineMacro("__ELF__");
|
||||
|
|
|
@ -61,9 +61,7 @@ public:
|
|||
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
|
||||
|
||||
bool validateAsmConstraint(const char *&Name,
|
||||
TargetInfo::ConstraintInfo &Info) const override {
|
||||
return false;
|
||||
}
|
||||
TargetInfo::ConstraintInfo &Info) const override;
|
||||
|
||||
bool hasFeature(StringRef Feature) const override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue