MC: support passing search paths to the IAS

This is needed to support inclusion in inline assembly via the
`.include` directive.

llvm-svn: 291085
This commit is contained in:
Saleem Abdulrasool 2017-01-05 05:56:39 +00:00
parent 1ab35fa7a8
commit 6252bd8eac
6 changed files with 33 additions and 1 deletions

View File

@ -11,6 +11,7 @@
#define LLVM_MC_MCTARGETOPTIONS_H
#include <string>
#include <vector>
namespace llvm {
@ -51,11 +52,17 @@ public:
bool PreserveAsmComments : 1;
int DwarfVersion;
/// getABIName - If this returns a non-empty string this represents the
/// textual name of the ABI that we want the backend to use, e.g. o32, or
/// aapcs-linux.
StringRef getABIName() const;
std::string ABIName;
/// Additional paths to search for `.include` directives when using the
/// integrated assembler.
std::vector<std::string> IASSearchPaths;
MCTargetOptions();
};
@ -75,7 +82,8 @@ inline bool operator==(const MCTargetOptions &LHS, const MCTargetOptions &RHS) {
ARE_EQUAL(ShowMCInst) &&
ARE_EQUAL(AsmVerbose) &&
ARE_EQUAL(DwarfVersion) &&
ARE_EQUAL(ABIName));
ARE_EQUAL(ABIName) &&
ARE_EQUAL(IASSearchPaths));
#undef ARE_EQUAL
}

View File

@ -100,6 +100,8 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
}
SourceMgr SrcMgr;
SrcMgr.setIncludeDirs(MCOptions.IASSearchPaths);
SrcMgrDiagInfo DiagInfo;
// If the current LLVMContext has an inline asm handler, set it in SourceMgr.

View File

@ -0,0 +1,13 @@
; RUN: llc -mtriple thumbv7--- -I %p/include -filetype asm -o - %s | FileCheck %s
module asm ".include \22module.x\22"
define arm_aapcscc void @f() {
entry:
call void asm sideeffect ".include \22function.x\22", ""()
ret void
}
; CHECK: MODULE = 1
; CHECK: FUNCTION = 1

View File

@ -0,0 +1,3 @@
FUNCTION = 1

View File

@ -0,0 +1,3 @@
MODULE = 1

View File

@ -134,6 +134,8 @@ static cl::opt<std::string> StartAfter("start-after",
cl::desc("Resume compilation after a specific pass"),
cl::value_desc("pass-name"), cl::init(""));
static cl::list<std::string> IncludeDirs("I", cl::desc("include search path"));
namespace {
static ManagedStatic<std::vector<std::string>> RunPassNames;
@ -398,6 +400,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
Options.MCOptions.AsmVerbose = AsmVerbose;
Options.MCOptions.PreserveAsmComments = PreserveComments;
Options.MCOptions.IASSearchPaths = IncludeDirs;
std::unique_ptr<TargetMachine> Target(
TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr, FeaturesStr,