1 #include "llvm/ADT/Triple.h"
2 #include "llvm/MC/TargetRegistry.h"
3 #include "llvm/Support/TargetSelect.h"
4 #include "llvm/Target/TargetMachine.h"
5 #include "gtest/gtest.h"
11 class AIXRelocModelTest
: public ::testing::Test
{
13 static void SetUpTestCase() {
14 LLVMInitializePowerPCTargetInfo();
15 LLVMInitializePowerPCTarget();
16 LLVMInitializePowerPCTargetMC();
20 TEST_F(AIXRelocModelTest
, DefalutToPIC
) {
21 Triple
TheTriple(/*ArchStr*/ "powerpc", /*VendorStr*/ "", /*OSStr*/ "aix");
23 const Target
*TheTarget
= TargetRegistry::lookupTarget("", TheTriple
, Error
);
24 ASSERT_TRUE(TheTarget
) << Error
;
26 TargetOptions Options
;
27 // Create a TargetMachine for powerpc--aix target, and deliberately leave its
28 // relocation model unset.
29 std::unique_ptr
<TargetMachine
> Target(TheTarget
->createTargetMachine(
30 /*TT*/ TheTriple
.getTriple(), /*CPU*/ "", /*Features*/ "",
31 /*Options*/ Options
, /*RM*/ None
, /*CM*/ None
,
32 /*OL*/ CodeGenOpt::Default
));
33 ASSERT_TRUE(Target
) << "Could not allocate target machine!";
35 // The relocation model on AIX should be forced to PIC regardless.
36 EXPECT_TRUE(Target
->getRelocationModel() == Reloc::PIC_
);
39 } // end of anonymous namespace