summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>2017-10-14 16:15:28 +0000
committerKonstantin Zhuravlyov <kzhuravl_dev@outlook.com>2017-10-14 16:15:28 +0000
commit219066bab87870160be2563298794b8cbe2e29f7 (patch)
tree8c1619109c6d4620e0e06eb731d3c243e8f2df48 /llvm/lib
parent2b8ad7312d6f0ebcd990ff9881659f4a77484896 (diff)
downloadbcm5719-llvm-219066bab87870160be2563298794b8cbe2e29f7.tar.gz
bcm5719-llvm-219066bab87870160be2563298794b8cbe2e29f7.zip
AMDGPU: Improve note directive verification in assembler
- Do not allow amd_amdgpu_isa directives on non-amdgcn architectures - Do not allow amd_amdgpu_hsa_metadata on non-amdhsa OSes - Do not allow amd_amdgpu_pal_metadata on non-amdpal OSes Differential Revision: https://reviews.llvm.org/D38750 llvm-svn: 315812
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 7f8c28e9c24..806aa420c50 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -2454,6 +2454,12 @@ bool AMDGPUAsmParser::ParseDirectiveAMDGPUHsaKernel() {
}
bool AMDGPUAsmParser::ParseDirectiveISAVersion() {
+ if (getSTI().getTargetTriple().getArch() != Triple::amdgcn) {
+ return Error(getParser().getTok().getLoc(),
+ ".amd_amdgpu_isa directive is not available on non-amdgcn "
+ "architectures");
+ }
+
auto ISAVersionStringFromASM = getLexer().getTok().getStringContents();
std::string ISAVersionStringFromSTI;
@@ -2473,6 +2479,12 @@ bool AMDGPUAsmParser::ParseDirectiveISAVersion() {
}
bool AMDGPUAsmParser::ParseDirectiveHSAMetadata() {
+ if (getSTI().getTargetTriple().getOS() != Triple::AMDHSA) {
+ return Error(getParser().getTok().getLoc(),
+ (Twine(HSAMD::AssemblerDirectiveBegin) + Twine(" directive is "
+ "not available on non-amdhsa OSes")).str());
+ }
+
std::string HSAMetadataString;
raw_string_ostream YamlStream(HSAMetadataString);
@@ -2504,7 +2516,7 @@ bool AMDGPUAsmParser::ParseDirectiveHSAMetadata() {
if (getLexer().is(AsmToken::Eof) && !FoundEnd) {
return TokError(Twine("expected directive ") +
- Twine(HSAMD::AssemblerDirectiveEnd) + Twine("not found"));
+ Twine(HSAMD::AssemblerDirectiveEnd) + Twine(" not found"));
}
YamlStream.flush();
@@ -2516,6 +2528,12 @@ bool AMDGPUAsmParser::ParseDirectiveHSAMetadata() {
}
bool AMDGPUAsmParser::ParseDirectivePALMetadata() {
+ if (getSTI().getTargetTriple().getOS() != Triple::AMDPAL) {
+ return Error(getParser().getTok().getLoc(),
+ (Twine(PALMD::AssemblerDirective) + Twine(" directive is "
+ "not available on non-amdpal OSes")).str());
+ }
+
PALMD::Metadata PALMetadata;
for (;;) {
uint32_t Value;
OpenPOWER on IntegriCloud