summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2018-04-11 16:08:00 +0000
committerYonghong Song <yhs@fb.com>2018-04-11 16:08:00 +0000
commit2ad75f7410d895b4d91cbf3d11634dfcedbb6ae2 (patch)
tree57b886ef9908274f1d58aee5b8b0be9cecc99a77 /clang
parent0828699488b0baaf532cda149877f1de1e11210b (diff)
downloadbcm5719-llvm-2ad75f7410d895b4d91cbf3d11634dfcedbb6ae2.tar.gz
bcm5719-llvm-2ad75f7410d895b4d91cbf3d11634dfcedbb6ae2.zip
bpf: accept all asm register names
Sometimes when people compile bpf programs with "clang ... -target bpf ...", the kernel header files may contain host arch inline assembly codes as in the patch https://patchwork.kernel.org/patch/10119683/ by Arnaldo Carvaldo de Melo. The current workaround in the above patch is to guard the inline assembly with "#ifndef __BPF__" marco. So when __BPF__ is defined, these macros will have no use. Such a method is not extensible. As a matter of fact, most of these inline assembly codes will be thrown away at the end of clang compilation. So for bpf target, this patch accepts all asm register names in clang AST stage. The name will be checked again during llc code generation if the inline assembly code is indeed for bpf programs. With this patch, the above "#ifndef __BPF__" is not needed any more in https://patchwork.kernel.org/patch/10119683/. Signed-off-by: Yonghong Song <yhs@fb.com> llvm-svn: 329823
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Basic/TargetInfo.h2
-rw-r--r--clang/lib/Basic/Targets/BPF.h1
2 files changed, 2 insertions, 1 deletions
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index 26f72a1814d..8fbda351ff3 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -619,7 +619,7 @@ public:
/// according to GCC.
///
/// This is used by Sema for inline asm statements.
- bool isValidGCCRegisterName(StringRef Name) const;
+ virtual bool isValidGCCRegisterName(StringRef Name) const;
/// \brief Returns the "normalized" GCC register name.
///
diff --git a/clang/lib/Basic/Targets/BPF.h b/clang/lib/Basic/Targets/BPF.h
index 36d2da4dbf3..61a7ddae9c9 100644
--- a/clang/lib/Basic/Targets/BPF.h
+++ b/clang/lib/Basic/Targets/BPF.h
@@ -63,6 +63,7 @@ public:
return TargetInfo::VoidPtrBuiltinVaList;
}
+ bool isValidGCCRegisterName(StringRef Name) const override { return true; }
ArrayRef<const char *> getGCCRegNames() const override { return None; }
bool validateAsmConstraint(const char *&Name,
OpenPOWER on IntegriCloud