Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions llvm/test/tools/llvm-snippy/mabi-affects-elf-abi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# RUN: llvm-snippy %s -o %t.elf -model-plugin None
# RUN: llvm-readelf -h %t.elf | FileCheck %s

options:
march: rv64gc
mtriple: riscv64
mabi: lp64d

include:
- Inputs/sections.yaml

histogram:
- [ADD, 1]

# CHECK: Machine: RISC-V
# CHECK: Flags: 0x5, RVC, double-float ABI
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct SelectedTargetInfo final {
std::string MArch;
std::string CPU;
std::string Features;
std::string ABI;
};

// An object to initialize LLVM and prepare objects needed to run the
Expand Down
5 changes: 4 additions & 1 deletion llvm/tools/llvm-snippy/lib/GeneratorUtils/LLVMState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ Expected<LLVMState> LLVMState::create(const SelectedTargetInfo &TargetInfo) {

TargetFeatures += ",";
TargetFeatures += TargetInfo.Features;
const TargetOptions Options;

TargetOptions Options;
Options.MCOptions.ABIName = TargetInfo.ABI;

auto TM = std::unique_ptr<TargetMachine>(static_cast<TargetMachine *>(
Tgt->createTargetMachine(TheTriple, TargetInfo.CPU, TargetFeatures,
Options, Reloc::Model::Static)));
Expand Down
2 changes: 2 additions & 0 deletions llvm/tools/llvm-snippy/llvm-snippy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ static SelectedTargetInfo getSelectedTargetInfo(const ProgramOptions &Opts) {
TargetInfo.Triple = Opts.MTargetTriple;
TargetInfo.CPU = Opts.CpuName;
TargetInfo.Features = Opts.MAttr;
TargetInfo.ABI = Opts.ABI;

if (!Opts.MTargetTriple.isSpecified()) {
TargetInfo.Triple = sys::getProcessTriple();
if (Opts.MArch.isSpecified())
Expand Down
Loading