Skip to content

Commit 24f49dc

Browse files
committed
Move the data layout computation to TargetParser so clang can use it
1 parent 6b58c6f commit 24f49dc

32 files changed

+701
-709
lines changed

llvm/benchmarks/RuntimeLibcalls.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ static std::vector<std::string> readSymbolsFromFile(StringRef InputFile) {
5454
// Hackily figure out if there's a prefix on the symbol names - llvm-nm
5555
// appears to not have a flag to skip this.
5656
llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
57-
std::string DummyDatalayout = "e";
58-
DummyDatalayout += DataLayout::getManglingComponent(HostTriple);
59-
60-
DataLayout DL(DummyDatalayout);
57+
DataLayout DL(HostTriple.computeDataLayout());
6158
char GlobalPrefix = DL.getGlobalPrefix();
6259

6360
std::vector<std::string> Lines;

llvm/include/llvm/IR/DataLayout.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,6 @@ class DataLayout {
194194
/// description on failure.
195195
LLVM_ABI static Expected<DataLayout> parse(StringRef LayoutString);
196196

197-
/// Given an LLVM target triple, compute the well-known datalayout string.
198-
/// TODO: Create a static factor helper version of this method and refactor
199-
/// the TargetMachine callers to use it.
200-
LLVM_ABI static std::string computeStringForTriple(const Triple &T,
201-
StringRef ABIName = "");
202-
203197
/// Layout endianness...
204198
bool isLittleEndian() const { return !BigEndian; }
205199
bool isBigEndian() const { return BigEndian; }
@@ -309,8 +303,6 @@ class DataLayout {
309303
llvm_unreachable("invalid mangling mode");
310304
}
311305

312-
LLVM_ABI static const char *getManglingComponent(const Triple &T);
313-
314306
/// Returns true if the specified type fits in a native integer type
315307
/// supported by the CPU.
316308
///

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,10 @@ class Triple {
13271327
const VersionTuple &Version);
13281328

13291329
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const;
1330+
1331+
/// Compute the LLVM IR data layout string based on the triple. Some targets
1332+
/// customize the layout based on the ABIName string.
1333+
LLVM_ABI std::string computeDataLayout(StringRef ABIName = "") const;
13301334
};
13311335

13321336
} // End llvm namespace

0 commit comments

Comments
 (0)