Skip to content

Commit 50116a2

Browse files
committed
MC: support passing search paths to the IAS
This is needed to support inclusion in inline assembly via the `.include` directive. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291085 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 6974a46 commit 50116a2

File tree

6 files changed

+33
-1
lines changed

6 files changed

+33
-1
lines changed

include/llvm/MC/MCTargetOptions.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define LLVM_MC_MCTARGETOPTIONS_H
1212

1313
#include <string>
14+
#include <vector>
1415

1516
namespace llvm {
1617

@@ -51,11 +52,17 @@ class MCTargetOptions {
5152
bool PreserveAsmComments : 1;
5253

5354
int DwarfVersion;
55+
5456
/// getABIName - If this returns a non-empty string this represents the
5557
/// textual name of the ABI that we want the backend to use, e.g. o32, or
5658
/// aapcs-linux.
5759
StringRef getABIName() const;
5860
std::string ABIName;
61+
62+
/// Additional paths to search for `.include` directives when using the
63+
/// integrated assembler.
64+
std::vector<std::string> IASSearchPaths;
65+
5966
MCTargetOptions();
6067
};
6168

@@ -75,7 +82,8 @@ inline bool operator==(const MCTargetOptions &LHS, const MCTargetOptions &RHS) {
7582
ARE_EQUAL(ShowMCInst) &&
7683
ARE_EQUAL(AsmVerbose) &&
7784
ARE_EQUAL(DwarfVersion) &&
78-
ARE_EQUAL(ABIName));
85+
ARE_EQUAL(ABIName) &&
86+
ARE_EQUAL(IASSearchPaths));
7987
#undef ARE_EQUAL
8088
}
8189

lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
100100
}
101101

102102
SourceMgr SrcMgr;
103+
SrcMgr.setIncludeDirs(MCOptions.IASSearchPaths);
104+
103105
SrcMgrDiagInfo DiagInfo;
104106

105107
// If the current LLVMContext has an inline asm handler, set it in SourceMgr.

test/MC/AsmParser/include.ll

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; RUN: llc -mtriple thumbv7--- -I %p/include -filetype asm -o - %s | FileCheck %s
2+
3+
module asm ".include \22module.x\22"
4+
5+
define arm_aapcscc void @f() {
6+
entry:
7+
call void asm sideeffect ".include \22function.x\22", ""()
8+
ret void
9+
}
10+
11+
; CHECK: MODULE = 1
12+
; CHECK: FUNCTION = 1
13+

test/MC/AsmParser/include/function.x

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
FUNCTION = 1
3+

test/MC/AsmParser/include/module.x

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
MODULE = 1
3+

tools/llc/llc.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ static cl::opt<std::string> StartAfter("start-after",
134134
cl::desc("Resume compilation after a specific pass"),
135135
cl::value_desc("pass-name"), cl::init(""));
136136

137+
static cl::list<std::string> IncludeDirs("I", cl::desc("include search path"));
138+
137139
namespace {
138140
static ManagedStatic<std::vector<std::string>> RunPassNames;
139141

@@ -398,6 +400,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
398400
Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
399401
Options.MCOptions.AsmVerbose = AsmVerbose;
400402
Options.MCOptions.PreserveAsmComments = PreserveComments;
403+
Options.MCOptions.IASSearchPaths = IncludeDirs;
401404

402405
std::unique_ptr<TargetMachine> Target(
403406
TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr, FeaturesStr,

0 commit comments

Comments
 (0)