Skip to content

Commit c39184f

Browse files
Remove Target Triple interface for Target Memory
1 parent 11acc4a commit c39184f

File tree

14 files changed

+73
-121
lines changed

14 files changed

+73
-121
lines changed

llvm/include/llvm/IR/Attributes.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "llvm/Support/Compiler.h"
2626
#include "llvm/Support/ModRef.h"
2727
#include "llvm/Support/PointerLikeTypeTraits.h"
28-
#include "llvm/TargetParser/Triple.h"
2928
#include <cassert>
3029
#include <cstdint>
3130
#include <optional>
@@ -315,8 +314,7 @@ class Attribute {
315314

316315
/// The Attribute is converted to a string of equivalent mnemonic. This
317316
/// is, presumably, for writing out the mnemonics for the assembly writer.
318-
LLVM_ABI std::string getAsString(const Triple *TT = nullptr,
319-
bool InAttrGrp = false) const;
317+
LLVM_ABI std::string getAsString(bool InAttrGrp = false) const;
320318

321319
/// Return true if this attribute belongs to the LLVMContext.
322320
LLVM_ABI bool hasParentContext(LLVMContext &C) const;
@@ -459,8 +457,7 @@ class AttributeSet {
459457
LLVM_ABI MemoryEffects getMemoryEffects() const;
460458
LLVM_ABI CaptureInfo getCaptureInfo() const;
461459
LLVM_ABI FPClassTest getNoFPClass() const;
462-
LLVM_ABI std::string getAsString(const Triple *TT = nullptr,
463-
bool InAttrGrp = false) const;
460+
LLVM_ABI std::string getAsString(bool InAttrGrp = false) const;
464461

465462
/// Return true if this attribute set belongs to the LLVMContext.
466463
LLVM_ABI bool hasParentContext(LLVMContext &C) const;

llvm/include/llvm/Support/ModRef.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ enum class ModRefInfo : uint8_t {
5757
LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, ModRefInfo MR);
5858

5959
enum class InaccessibleTargetMemLocation {
60-
MEM_TARGET_0 = 3,
61-
MEM_TARGET_1 = 4,
60+
TargetMem0 = 3,
61+
TargetMem1 = 4,
6262
};
6363

6464
/// The locations at which a function might access memory.
@@ -277,9 +277,9 @@ template <typename LocationEnum> class MemoryEffectsBase {
277277
/// Whether this function only (at most) accesses inaccessible memory.
278278
bool onlyAccessesInaccessibleMem() const {
279279
return getWithoutLoc(static_cast<IRMemLocation>(
280-
llvm::InaccessibleTargetMemLocation::MEM_TARGET_0))
280+
llvm::InaccessibleTargetMemLocation::TargetMem0))
281281
.getWithoutLoc(static_cast<IRMemLocation>(
282-
llvm::InaccessibleTargetMemLocation::MEM_TARGET_1))
282+
llvm::InaccessibleTargetMemLocation::TargetMem1))
283283
.getWithoutLoc(Location::InaccessibleMem)
284284
.doesNotAccessMemory();
285285
}

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,6 @@ class Triple {
322322
XCOFF,
323323
};
324324

325-
// This should be a copy from enum class InaccessibleTargetMemLocation
326-
// in ModRef.h
327-
enum class InaccessibleTargetMemLocation : uint8_t {
328-
MEM_TARGET_0 = 3,
329-
MEM_TARGET_1 = 4,
330-
// Reserve more if/when needed
331-
Last
332-
};
333-
334325
private:
335326
std::string Data;
336327

@@ -1189,11 +1180,6 @@ class Triple {
11891180
/// Tests if the environment supports dllimport/export annotations.
11901181
bool hasDLLImportExport() const { return isOSWindows() || isPS(); }
11911182

1192-
StringRef
1193-
aarch64GetTargetMemLocName(InaccessibleTargetMemLocation Kind) const;
1194-
1195-
StringRef getTargetMemLocName(InaccessibleTargetMemLocation Kind) const;
1196-
11971183
/// @}
11981184
/// @name Mutators
11991185
/// @{

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,10 +1676,10 @@ static std::optional<MemoryEffects::Location> keywordToLoc(lltok::Kind Tok) {
16761676
return IRMemLocation::ErrnoMem;
16771677
case lltok::kw_aarch64_fpmr:
16781678
return static_cast<IRMemLocation>(
1679-
llvm::InaccessibleTargetMemLocation::MEM_TARGET_0);
1679+
llvm::InaccessibleTargetMemLocation::TargetMem0);
16801680
case lltok::kw_aarch64_za:
16811681
return static_cast<IRMemLocation>(
1682-
llvm::InaccessibleTargetMemLocation::MEM_TARGET_1);
1682+
llvm::InaccessibleTargetMemLocation::TargetMem1);
16831683
default:
16841684
return std::nullopt;
16851685
}

llvm/lib/IR/AsmWriter.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2902,7 +2902,7 @@ class AssemblyWriter {
29022902
void writeMDNode(unsigned Slot, const MDNode *Node);
29032903
void writeAttribute(const Attribute &Attr, bool InAttrGroup = false);
29042904
void writeAttributeSet(const AttributeSet &AttrSet, bool InAttrGroup = false);
2905-
void writeAllAttributeGroups(const Triple *TT = nullptr);
2905+
void writeAllAttributeGroups();
29062906

29072907
void printTypeIdentities();
29082908
void printGlobal(const GlobalVariable *GV);
@@ -3173,7 +3173,7 @@ void AssemblyWriter::printModule(const Module *M) {
31733173
// Output all attribute groups.
31743174
if (!Machine.as_empty()) {
31753175
Out << '\n';
3176-
writeAllAttributeGroups(&M->getTargetTriple());
3176+
writeAllAttributeGroups();
31773177
}
31783178

31793179
// Output named metadata.
@@ -4126,7 +4126,7 @@ void AssemblyWriter::printFunction(const Function *F) {
41264126
for (const Attribute &Attr : AS) {
41274127
if (!Attr.isStringAttribute()) {
41284128
if (!AttrStr.empty()) AttrStr += ' ';
4129-
AttrStr += Attr.getAsString(&F->getParent()->getTargetTriple(), false);
4129+
AttrStr += Attr.getAsString();
41304130
}
41314131
}
41324132

@@ -4973,9 +4973,8 @@ void AssemblyWriter::printMDNodeBody(const MDNode *Node) {
49734973
}
49744974

49754975
void AssemblyWriter::writeAttribute(const Attribute &Attr, bool InAttrGroup) {
4976-
llvm::Triple *TT;
49774976
if (!Attr.isTypeAttribute()) {
4978-
Out << Attr.getAsString(TT, InAttrGroup);
4977+
Out << Attr.getAsString(InAttrGroup);
49794978
return;
49804979
}
49814980

@@ -4998,16 +4997,16 @@ void AssemblyWriter::writeAttributeSet(const AttributeSet &AttrSet,
49984997
}
49994998
}
50004999

5001-
void AssemblyWriter::writeAllAttributeGroups(const Triple *TT) {
5000+
void AssemblyWriter::writeAllAttributeGroups() {
50025001
std::vector<std::pair<AttributeSet, unsigned>> asVec;
50035002
asVec.resize(Machine.as_size());
50045003

50055004
for (auto &I : llvm::make_range(Machine.as_begin(), Machine.as_end()))
50065005
asVec[I.second] = I;
50075006

50085007
for (const auto &I : asVec)
5009-
Out << "attributes #" << I.second << " = { "
5010-
<< I.first.getAsString(TT, true) << " }\n";
5008+
Out << "attributes #" << I.second << " = { " << I.first.getAsString(true)
5009+
<< " }\n";
50115010
}
50125011

50135012
void AssemblyWriter::printUseListOrder(const Value *V,

llvm/lib/IR/AttributeImpl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ class AttributeSetNode final
342342
MemoryEffects getMemoryEffects() const;
343343
CaptureInfo getCaptureInfo() const;
344344
FPClassTest getNoFPClass() const;
345-
std::string getAsString(const Triple *TT = nullptr,
346-
bool InAttrGrp = false) const;
345+
std::string getAsString(bool InAttrGrp) const;
347346
Type *getAttributeType(Attribute::AttrKind Kind) const;
348347

349348
using iterator = const Attribute *;

llvm/lib/IR/Attributes.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static const char *getModRefStr(ModRefInfo MR) {
533533
llvm_unreachable("Invalid ModRefInfo");
534534
}
535535

536-
std::string Attribute::getAsString(const Triple *TT, bool InAttrGrp) const {
536+
std::string Attribute::getAsString(bool InAttrGrp) const {
537537
if (!pImpl) return {};
538538

539539
if (isEnumAttribute())
@@ -663,12 +663,10 @@ std::string Attribute::getAsString(const Triple *TT, bool InAttrGrp) const {
663663
default: {
664664
InaccessibleTargetMemLocation TargetLoc =
665665
static_cast<InaccessibleTargetMemLocation>(Loc);
666-
if (TargetLoc == InaccessibleTargetMemLocation::MEM_TARGET_0)
667-
OS << TT->getTargetMemLocName(
668-
static_cast<Triple::InaccessibleTargetMemLocation>(TargetLoc));
669-
if (TargetLoc == InaccessibleTargetMemLocation::MEM_TARGET_1)
670-
OS << TT->getTargetMemLocName(
671-
static_cast<Triple::InaccessibleTargetMemLocation>(TargetLoc));
666+
if (TargetLoc == InaccessibleTargetMemLocation::TargetMem0)
667+
OS << "target_mem0 ";
668+
if (TargetLoc == InaccessibleTargetMemLocation::TargetMem1)
669+
OS << "target_mem1 ";
672670
OS << ": ";
673671
break;
674672
}
@@ -1222,8 +1220,8 @@ FPClassTest AttributeSet::getNoFPClass() const {
12221220
return SetNode ? SetNode->getNoFPClass() : fcNone;
12231221
}
12241222

1225-
std::string AttributeSet::getAsString(const Triple *TT, bool InAttrGrp) const {
1226-
return SetNode ? SetNode->getAsString(TT, InAttrGrp) : "";
1223+
std::string AttributeSet::getAsString(bool InAttrGrp) const {
1224+
return SetNode ? SetNode->getAsString(InAttrGrp) : "";
12271225
}
12281226

12291227
bool AttributeSet::hasParentContext(LLVMContext &C) const {
@@ -1246,7 +1244,7 @@ AttributeSet::iterator AttributeSet::end() const {
12461244
LLVM_DUMP_METHOD void AttributeSet::dump() const {
12471245
dbgs() << "AS =\n";
12481246
dbgs() << " { ";
1249-
dbgs() << getAsString(nullptr, true) << " }\n";
1247+
dbgs() << getAsString(true) << " }\n";
12501248
}
12511249
#endif
12521250

@@ -1418,13 +1416,12 @@ FPClassTest AttributeSetNode::getNoFPClass() const {
14181416
return fcNone;
14191417
}
14201418

1421-
std::string AttributeSetNode::getAsString(const Triple *TT,
1422-
bool InAttrGrp) const {
1419+
std::string AttributeSetNode::getAsString(bool InAttrGrp) const {
14231420
std::string Str;
14241421
for (iterator I = begin(), E = end(); I != E; ++I) {
14251422
if (I != begin())
14261423
Str += ' ';
1427-
Str += I->getAsString(TT, InAttrGrp);
1424+
Str += I->getAsString(InAttrGrp);
14281425
}
14291426
return Str;
14301427
}
@@ -2015,7 +2012,7 @@ MemoryEffects AttributeList::getMemoryEffects() const {
20152012
}
20162013

20172014
std::string AttributeList::getAsString(unsigned Index, bool InAttrGrp) const {
2018-
return getAttributes(Index).getAsString(nullptr, InAttrGrp);
2015+
return getAttributes(Index).getAsString(InAttrGrp);
20192016
}
20202017

20212018
AttributeSet AttributeList::getAttributes(unsigned Index) const {

llvm/lib/Support/ModRef.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, MemoryEffects ME) {
5252
default: {
5353
InaccessibleTargetMemLocation TargetLoc =
5454
static_cast<InaccessibleTargetMemLocation>(Loc);
55-
if (TargetLoc == InaccessibleTargetMemLocation::MEM_TARGET_0)
56-
OS << "MEM_TARGET_0: ";
57-
if (TargetLoc == InaccessibleTargetMemLocation::MEM_TARGET_1)
58-
OS << "MEM_TARGET_1: ";
55+
if (TargetLoc == InaccessibleTargetMemLocation::TargetMem0)
56+
OS << "TargetMem0: ";
57+
if (TargetLoc == InaccessibleTargetMemLocation::TargetMem1)
58+
OS << "TargetMem1: ";
5959
break;
6060
}
6161
}

llvm/lib/TargetParser/Triple.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,31 +2306,6 @@ ExceptionHandling Triple::getDefaultExceptionHandling() const {
23062306
return ExceptionHandling::None;
23072307
}
23082308

2309-
StringRef Triple::aarch64GetTargetMemLocName(
2310-
Triple::InaccessibleTargetMemLocation Kind) const {
2311-
switch (Kind) {
2312-
case InaccessibleTargetMemLocation::MEM_TARGET_0:
2313-
return "aarch64_fprm";
2314-
case InaccessibleTargetMemLocation::MEM_TARGET_1:
2315-
return "aarch64_za";
2316-
}
2317-
}
2318-
2319-
StringRef
2320-
Triple::getTargetMemLocName(InaccessibleTargetMemLocation Kind) const {
2321-
2322-
if (isAArch64())
2323-
return aarch64GetTargetMemLocName(Kind);
2324-
2325-
switch (Kind) {
2326-
case InaccessibleTargetMemLocation::MEM_TARGET_0:
2327-
return "mem_target_0";
2328-
case InaccessibleTargetMemLocation::MEM_TARGET_1:
2329-
return "mem_target_1";
2330-
}
2331-
return "unkown";
2332-
}
2333-
23342309
// HLSL triple environment orders are relied on in the front end
23352310
static_assert(Triple::Vertex - Triple::Pixel == 1,
23362311
"incorrect HLSL stage order");

llvm/test/Assembler/aarch64-memory-attribute.ll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@
33
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
44
target triple = "aarch64"
55

6-
; CHECK: Function Attrs: memory(aarch64_za: write)
6+
; CHECK: Function Attrs: memory(target_mem1 : write)
77
; CHECK: @fn_inaccessiblemem_write_aarch64_za() [[ATTR0:#.*]]
88
declare void @fn_inaccessiblemem_write_aarch64_za()
99
memory(aarch64_za: write)
1010

11-
; CHECK: Function Attrs: memory(aarch64_za: read)
11+
; CHECK: Function Attrs: memory(target_mem1 : read)
1212
; CHECK: @fn_inaccessiblemem_read_aarch64_za() [[ATTR1:#.*]]
1313
declare void @fn_inaccessiblemem_read_aarch64_za()
1414
memory(aarch64_za: read)
1515

16-
; CHECK: Function Attrs: memory(aarch64_fprm: write)
16+
; CHECK: Function Attrs: memory(target_mem0 : write)
1717
; CHECK: @fn_inaccessiblemem_write_aarch64_fpmr() [[ATTR2:#.*]]
1818
declare void @fn_inaccessiblemem_write_aarch64_fpmr()
1919
memory(aarch64_fpmr: write)
2020

21-
; CHECK: ; Function Attrs: memory(aarch64_fprm: read)
21+
; CHECK: ; Function Attrs: memory(target_mem0 : read)
2222
; CHECK: @fn_inaccessiblemem_read_aarch64_fpmr() [[ATTR3:#.*]]
2323
declare void @fn_inaccessiblemem_read_aarch64_fpmr()
2424
memory(aarch64_fpmr: read)
2525

26-
; CHECK: Function Attrs: memory(aarch64_fprm: read, aarch64_za: write)
26+
; CHECK: Function Attrs: memory(target_mem0 : read, target_mem1 : write)
2727
; CHECK: @fn_inaccessiblemem_read_aarch64_fpmr_write_aarch64_za() [[ATTR4:#.*]]
2828
declare void @fn_inaccessiblemem_read_aarch64_fpmr_write_aarch64_za()
2929
memory(aarch64_fpmr: read, aarch64_za: write)
3030

31-
; CHECK: attributes [[ATTR0]] = { memory(aarch64_za: write) }
32-
; CHECK: attributes [[ATTR1]] = { memory(aarch64_za: read) }
33-
; CHECK: attributes [[ATTR2]] = { memory(aarch64_fprm: write) }
34-
; CHECK: attributes [[ATTR3]] = { memory(aarch64_fprm: read) }
35-
; CHECK: attributes [[ATTR4]] = { memory(aarch64_fprm: read, aarch64_za: write) }
31+
; CHECK: attributes [[ATTR0]] = { memory(target_mem1 : write) }
32+
; CHECK: attributes [[ATTR1]] = { memory(target_mem1 : read) }
33+
; CHECK: attributes [[ATTR2]] = { memory(target_mem0 : write) }
34+
; CHECK: attributes [[ATTR3]] = { memory(target_mem0 : read) }
35+
; CHECK: attributes [[ATTR4]] = { memory(target_mem0 : read, target_mem1 : write) }

0 commit comments

Comments
 (0)