Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,10 @@ void AArch64AsmPrinter::emitAttributes(unsigned Flags,
AArch64BuildAttrs::SubsectionType::ULEB128);
TS->emitAttribute(
AArch64BuildAttrs::getVendorName(AArch64BuildAttrs::AEABI_PAUTHABI),
AArch64BuildAttrs::TAG_PAUTH_PLATFORM, PAuthABIPlatform, "", false);
AArch64BuildAttrs::TAG_PAUTH_PLATFORM, PAuthABIPlatform, "");
TS->emitAttribute(
AArch64BuildAttrs::getVendorName(AArch64BuildAttrs::AEABI_PAUTHABI),
AArch64BuildAttrs::TAG_PAUTH_SCHEMA, PAuthABIVersion, "", false);
AArch64BuildAttrs::TAG_PAUTH_SCHEMA, PAuthABIVersion, "");
}

unsigned BTIValue = (Flags & AArch64BuildAttrs::Feature_BTI_Flag) ? 1 : 0;
Expand All @@ -499,13 +499,13 @@ void AArch64AsmPrinter::emitAttributes(unsigned Flags,
AArch64BuildAttrs::SubsectionType::ULEB128);
TS->emitAttribute(AArch64BuildAttrs::getVendorName(
AArch64BuildAttrs::AEABI_FEATURE_AND_BITS),
AArch64BuildAttrs::TAG_FEATURE_BTI, BTIValue, "", false);
AArch64BuildAttrs::TAG_FEATURE_BTI, BTIValue, "");
TS->emitAttribute(AArch64BuildAttrs::getVendorName(
AArch64BuildAttrs::AEABI_FEATURE_AND_BITS),
AArch64BuildAttrs::TAG_FEATURE_PAC, PACValue, "", false);
AArch64BuildAttrs::TAG_FEATURE_PAC, PACValue, "");
TS->emitAttribute(AArch64BuildAttrs::getVendorName(
AArch64BuildAttrs::AEABI_FEATURE_AND_BITS),
AArch64BuildAttrs::TAG_FEATURE_GCS, GCSValue, "", false);
AArch64BuildAttrs::TAG_FEATURE_GCS, GCSValue, "");
}
}

Expand Down
38 changes: 19 additions & 19 deletions llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7870,8 +7870,7 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) {
IsOptional = AArch64BuildAttrs::getOptionalID(Optionality);
if (AArch64BuildAttrs::OPTIONAL_NOT_FOUND == IsOptional) {
Error(Parser.getTok().getLoc(),
AArch64BuildAttrs::getSubsectionOptionalUnknownError() + ": " +
Optionality);
AArch64BuildAttrs::getSubsectionOptionalUnknownError());
return true;
}
if (SubsectionExists) {
Expand Down Expand Up @@ -7919,7 +7918,7 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) {
Type = AArch64BuildAttrs::getTypeID(Name);
if (AArch64BuildAttrs::TYPE_NOT_FOUND == Type) {
Error(Parser.getTok().getLoc(),
AArch64BuildAttrs::getSubsectionTypeUnknownError() + ": " + Name);
AArch64BuildAttrs::getSubsectionTypeUnknownError());
return true;
}
if (SubsectionExists) {
Expand Down Expand Up @@ -7948,6 +7947,7 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) {
}
}
Parser.Lex();

// Parsing finished, check for trailing tokens.
if (Parser.getTok().isNot(llvm::AsmToken::EndOfStatement)) {
Error(Parser.getTok().getLoc(), "unexpected token for AArch64 build "
Expand Down Expand Up @@ -7986,14 +7986,18 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) {

StringRef TagStr = "";
unsigned Tag;
if (Parser.getTok().is(AsmToken::Identifier)) {
if (Parser.getTok().is(AsmToken::Integer)) {
Tag = getTok().getIntVal();
} else if (Parser.getTok().is(AsmToken::Identifier)) {
TagStr = Parser.getTok().getIdentifier();
switch (ActiveSubsectionID) {
default:
assert(0 && "Subsection name error");
break;
case AArch64BuildAttrs::VENDOR_UNKNOWN:
// Private subsection, accept any tag.
// Tag was provided as an unrecognized string instead of an unsigned
// integer
Error(Parser.getTok().getLoc(), "unrecognized Tag: '" + TagStr +
"' \nExcept for public subsections, "
"tags have to be an unsigned int.");
return true;
break;
case AArch64BuildAttrs::AEABI_PAUTHABI:
Tag = AArch64BuildAttrs::getPauthABITagsID(TagStr);
Expand All @@ -8014,8 +8018,6 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) {
}
break;
}
} else if (Parser.getTok().is(AsmToken::Integer)) {
Tag = getTok().getIntVal();
} else {
Error(Parser.getTok().getLoc(), "AArch64 build attributes tag not found");
return true;
Expand Down Expand Up @@ -8059,10 +8061,9 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) {
Error(Parser.getTok().getLoc(), "AArch64 build attributes value not found");
return true;
}
// Check for possible unaccepted values for known tags (AEABI_PAUTHABI,
// AEABI_FEATURE_AND_BITS)
if (!(ActiveSubsectionID == AArch64BuildAttrs::VENDOR_UNKNOWN) &&
TagStr != "") { // TagStr was a recognized string
// Check for possible unaccepted values for known tags
// (AEABI_FEATURE_AND_BITS)
if (ActiveSubsectionID == AArch64BuildAttrs::AEABI_FEATURE_AND_BITS) {
if (0 != ValueInt && 1 != ValueInt) {
Error(Parser.getTok().getLoc(),
"unknown AArch64 build attributes Value for Tag '" + TagStr +
Expand All @@ -8071,7 +8072,8 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) {
}
}
Parser.Lex();
// Parsing finished, check for trailing tokens.

// Parsing finished. Check for trailing tokens.
if (Parser.getTok().isNot(llvm::AsmToken::EndOfStatement)) {
Error(Parser.getTok().getLoc(),
"unexpected token for AArch64 build attributes tag and value "
Expand All @@ -8080,13 +8082,11 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) {
}

if (unsigned(-1) != ValueInt) {
getTargetStreamer().emitAttribute(ActiveSubsectionName, Tag, ValueInt, "",
false);
getTargetStreamer().emitAttribute(ActiveSubsectionName, Tag, ValueInt, "");
}

if ("" != ValueStr) {
getTargetStreamer().emitAttribute(ActiveSubsectionName, Tag, unsigned(-1),
ValueStr, false);
ValueStr);
}
return false;
}
Expand Down
36 changes: 15 additions & 21 deletions llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer {
}

void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value,
std::string String, bool Override) override {
std::string String) override {

// AArch64 build attributes for assembly attribute form:
// .aeabi_attribute tag, value
Expand All @@ -169,13 +169,12 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer {
case AArch64BuildAttrs::VENDOR_UNKNOWN:
if (unsigned(-1) != Value) {
OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value;
AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "",
Override);
AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "");
}
if ("" != String) {
OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << String;
AArch64TargetStreamer::emitAttribute(VendorName, Tag, unsigned(-1),
String, Override);
String);
}
break;
// Note: AEABI_FEATURE_AND_BITS takes only unsigned values
Expand All @@ -185,16 +184,14 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer {
OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value;
// Keep the data structure consistent with the case of ELF emission
// (important for llvm-mc asm parsing)
AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "",
Override);
AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "");
break;
case AArch64BuildAttrs::TAG_FEATURE_BTI:
case AArch64BuildAttrs::TAG_FEATURE_GCS:
case AArch64BuildAttrs::TAG_FEATURE_PAC:
OS << "\t.aeabi_attribute" << "\t"
<< AArch64BuildAttrs::getFeatureAndBitsTagsStr(Tag) << ", " << Value;
AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "",
Override);
OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value << "\t// "
<< AArch64BuildAttrs::getFeatureAndBitsTagsStr(Tag);
AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "");
break;
}
break;
Expand All @@ -205,15 +202,13 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer {
OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value;
// Keep the data structure consistent with the case of ELF emission
// (important for llvm-mc asm parsing)
AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "",
Override);
AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "");
break;
case AArch64BuildAttrs::TAG_PAUTH_PLATFORM:
case AArch64BuildAttrs::TAG_PAUTH_SCHEMA:
OS << "\t.aeabi_attribute" << "\t"
<< AArch64BuildAttrs::getPauthABITagsStr(Tag) << ", " << Value;
AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "",
Override);
OS << "\t.aeabi_attribute" << "\t" << Tag << ", " << Value << "\t// "
<< AArch64BuildAttrs::getPauthABITagsStr(Tag);
AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "");
break;
}
break;
Expand Down Expand Up @@ -426,13 +421,12 @@ void AArch64TargetELFStreamer::emitAtributesSubsection(
}

void AArch64TargetELFStreamer::emitAttribute(StringRef VendorName, unsigned Tag,
unsigned Value, std::string String,
bool Override) {
unsigned Value,
std::string String) {
if (unsigned(-1) != Value)
AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "", Override);
AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "");
if ("" != String)
AArch64TargetStreamer::emitAttribute(VendorName, Tag, unsigned(-1), String,
Override);
AArch64TargetStreamer::emitAttribute(VendorName, Tag, unsigned(-1), String);
}

void AArch64TargetELFStreamer::emitInst(uint32_t Inst) {
Expand Down
30 changes: 14 additions & 16 deletions llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/MC/ConstantPools.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCELFStreamer.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSubtargetInfo.h"
Expand Down Expand Up @@ -193,8 +194,7 @@ AArch64TargetStreamer::getAtributesSubsectionByName(StringRef Name) {
}

void AArch64TargetStreamer::emitAttribute(StringRef VendorName, unsigned Tag,
unsigned Value, std::string String,
bool Override) {
unsigned Value, std::string String) {

if (unsigned(-1) == Value && "" == String) {
assert(0 && "Arguments error");
Expand All @@ -214,22 +214,20 @@ void AArch64TargetStreamer::emitAttribute(StringRef VendorName, unsigned Tag,
return;
}
for (MCELFStreamer::AttributeItem &Item : SubSection.Content) {
// Tag already exists
if (Item.Tag == Tag) {
if (!Override) {
if ((unsigned(-1) != Value && Item.IntValue != Value) ||
("" != String && Item.StringValue != String)) {
assert(0 &&
"Can not add AArch64 build attribute: An attribute with "
"the same tag and a different value already exists");
return;
} else {
// Case Item.IntValue == Value, no need to emit twice
assert(0 &&
"AArch64 build attribute: An attribute with the same tag "
"and a same value already exists");
return;
}
// New value for existing tag: update tag
if ((unsigned(-1) != Value && Item.IntValue != Value) ||
("" != String && Item.StringValue != String)) {
Item.Type = unsigned(-1) != Value
? MCELFStreamer::AttributeItem::NumericAttribute
: MCELFStreamer::AttributeItem::TextAttribute;
Item.IntValue = unsigned(-1) != Value ? Value : unsigned(-1);
Item.StringValue = unsigned(-1) != Value ? "" : String;
return;
}
// Same value for existing tag: do nothing
return;
}
}
if (unsigned(-1) != Value)
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class AArch64TargetStreamer : public MCTargetStreamer {
AArch64BuildAttrs::SubsectionOptional IsOptional,
AArch64BuildAttrs::SubsectionType ParameterType);
virtual void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value,
std::string String, bool Override);
std::string String);
void activateAtributesSubsection(StringRef VendorName);
std::unique_ptr<MCELFStreamer::AttributeSubSection>
getActiveAtributesSubsection();
Expand All @@ -127,7 +127,7 @@ class AArch64TargetELFStreamer : public AArch64TargetStreamer {
StringRef VendorName, AArch64BuildAttrs::SubsectionOptional IsOptional,
AArch64BuildAttrs::SubsectionType ParameterType) override;
void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value,
std::string String, bool Override = false) override;
std::string String) override;
void emitInst(uint32_t Inst) override;
void emitDirectiveVariantPCS(MCSymbol *Symbol) override;
void finish() override;
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF

; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128
; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 1
; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 1
; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 1
; ASM-NEXT: .aeabi_attribute 0, 1 // Tag_Feature_BTI
; ASM-NEXT: .aeabi_attribute 1, 1 // Tag_Feature_PAC
; ASM-NEXT: .aeabi_attribute 2, 1 // Tag_Feature_GCS

; ELF: Hex dump of section '.ARM.attributes':
; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/AArch64/aarch64-build-attributes-bti.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF

; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128
; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 1
; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 0
; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 0
; ASM-NEXT: .aeabi_attribute 0, 1 // Tag_Feature_BTI
; ASM-NEXT: .aeabi_attribute 1, 0 // Tag_Feature_PAC
; ASM-NEXT: .aeabi_attribute 2, 0 // Tag_Feature_GCS

; ELF: Hex dump of section '.ARM.attributes':
; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/AArch64/aarch64-build-attributes-gcs.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF

; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128
; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 0
; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 0
; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 1
; ASM-NEXT: .aeabi_attribute 0, 0 // Tag_Feature_BTI
; ASM-NEXT: .aeabi_attribute 1, 0 // Tag_Feature_PAC
; ASM-NEXT: .aeabi_attribute 2, 1 // Tag_Feature_GCS

; ELF: Hex dump of section '.ARM.attributes':
; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/AArch64/aarch64-build-attributes-pac.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF

; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128
; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 0
; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 1
; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 0
; ASM-NEXT: .aeabi_attribute 0, 0 // Tag_Feature_BTI
; ASM-NEXT: .aeabi_attribute 1, 1 // Tag_Feature_PAC
; ASM-NEXT: .aeabi_attribute 2, 0 // Tag_Feature_GCS

; ELF: Hex dump of section '.ARM.attributes':
; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF

; ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128
; ASM-NEXT: .aeabi_attribute Tag_PAuth_Platform, 2
; ASM-NEXT: .aeabi_attribute Tag_PAuth_Schema, 31
; ASM-NEXT: .aeabi_attribute 1, 2 // Tag_PAuth_Platform
; ASM-NEXT: .aeabi_attribute 2, 31 // Tag_PAuth_Schema

; ELF: Hex dump of section '.ARM.attributes':
; ELF-NEXT: 0x00000000 41190000 00616561 62695f70 61757468 A....aeabi_pauth
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// RUN: llvm-mc -triple=aarch64 %s -o - | FileCheck %s --check-prefix=ASM
// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF

// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128
// ASM: .aeabi_attribute 1, 7 // Tag_PAuth_Platform
// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema
// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema
// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128
// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI
// ASM: .aeabi_attribute 1, 1 // Tag_Feature_PAC
// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS
// ASM: .aeabi_subsection aeabi_pauthabi, required, uleb128
// ASM: .aeabi_attribute 1, 7 // Tag_PAuth_Platform
// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema
// ASM: .aeabi_attribute 2, 777 // Tag_PAuth_Schema
// ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128
// ASM: .aeabi_attribute 0, 1 // Tag_Feature_BTI
// ASM: .aeabi_attribute 1, 1 // Tag_Feature_PAC
// ASM: .aeabi_attribute 2, 1 // Tag_Feature_GCS

// ELF: Hex dump of section '.ARM.attributes':
// ELF: 0x00000000 411a0000 00616561 62695f70 61757468 A....aeabi_pauth
// ELF: 0x00000010 61626900 00000107 02890623 00000061 abi........#...a
// ELF: 0x00000020 65616269 5f666561 74757265 5f616e64 eabi_feature_and
// ELF: 0x00000030 5f626974 73000100 00010101 0201 _bits.........


.aeabi_subsection aeabi_pauthabi, required, uleb128 // test header comment
.aeabi_attribute Tag_PAuth_Platform, 7
.aeabi_attribute Tag_PAuth_Schema, 777
.aeabi_attribute Tag_PAuth_Schema, 777
.aeabi_subsection aeabi_feature_and_bits, optional, uleb128
.aeabi_attribute Tag_Feature_BTI, 1
.aeabi_attribute Tag_Feature_PAC, 1
.aeabi_attribute Tag_Feature_GCS, 1
.aeabi_subsection aeabi_pauthabi, required, uleb128
.aeabi_attribute 1, 7 // Tag_PAuth_Platform
.aeabi_attribute 2, 777 // Tag_PAuth_Schema
.aeabi_attribute 2, 777 // Tag_PAuth_Schema
.aeabi_subsection aeabi_feature_and_bits, optional, uleb128
.aeabi_attribute 0, 1 // Tag_Feature_BTI
.aeabi_attribute 1, 1 // Tag_Feature_PAC
.aeabi_attribute 2, 1 // Tag_Feature_GCS
Loading