"src/include/amd_inline_asm.hip.hpp" did not exist on "155d78594ba72bda749152db492c0872dd41be97"
Commit 8ec57337 authored by dugupeiwen's avatar dugupeiwen
Browse files

adapt for DTK clang-14

parent 55ada7af
...@@ -16,9 +16,9 @@ add_library( ...@@ -16,9 +16,9 @@ add_library(
llvm_map_components_to_libnames( llvm_map_components_to_libnames(
llvm_libs # this name is magic, it is the variable in which the llvm_libs # this name is magic, it is the variable in which the
# component linker info is stored. # component linker info is stored.
#all all
amdgpuasmparser amdgpuasmparser
amdgpuasmprinter # amdgpuasmprinter
amdgpucodegen amdgpucodegen
amdgpudesc amdgpudesc
amdgpudisassembler amdgpudisassembler
...@@ -45,5 +45,6 @@ set_target_properties(rocmlite PROPERTIES ...@@ -45,5 +45,6 @@ set_target_properties(rocmlite PROPERTIES
# Add in test dir # Add in test dir
# add_subdirectory(googletest)
add_subdirectory(test) add_subdirectory(test)
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
#include "llvm/AsmParser/Parser.h" #include "llvm/AsmParser/Parser.h"
#include "llvm/Bitcode/BitcodeWriterPass.h" #include "llvm/Bitcode/BitcodeWriterPass.h"
#include "llvm/Bitcode/BitcodeReader.h" #include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/CodeGen/CommandFlags.def" // #include "llvm/CodeGen/CommandFlags.def"
#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/CodeGen/LinkAllAsmWriterComponents.h" #include "llvm/CodeGen/LinkAllAsmWriterComponents.h"
#include "llvm/CodeGen/LinkAllCodegenComponents.h" #include "llvm/CodeGen/LinkAllCodegenComponents.h"
#include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineFunctionPass.h"
...@@ -48,7 +49,7 @@ ...@@ -48,7 +49,7 @@
#include "llvm/Support/Signals.h" #include "llvm/Support/Signals.h"
#include "llvm/Support/SourceMgr.h" #include "llvm/Support/SourceMgr.h"
#include "llvm/Support/SystemUtils.h" #include "llvm/Support/SystemUtils.h"
#include "llvm/Support/TargetRegistry.h" #include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h" #include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/YAMLTraits.h" #include "llvm/Support/YAMLTraits.h"
...@@ -63,7 +64,7 @@ ...@@ -63,7 +64,7 @@
namespace librocmlite namespace librocmlite
{ {
using namespace llvm;
static llvm::LLVMContext *TheContext = nullptr; static llvm::LLVMContext *TheContext = nullptr;
bool DisableInline = false; bool DisableInline = false;
...@@ -76,6 +77,7 @@ namespace librocmlite ...@@ -76,6 +77,7 @@ namespace librocmlite
static const std::string MArch = "amdgcn"; // AMD Graphics Core Next static const std::string MArch = "amdgcn"; // AMD Graphics Core Next
static llvm::codegen::RegisterCodeGenFlags CodeGenFlags;
// ModuleRef impl // ModuleRef impl
ModuleRef::ModuleRef(Module * module) : M(module) { }; ModuleRef::ModuleRef(Module * module) : M(module) { };
...@@ -98,7 +100,7 @@ namespace librocmlite ...@@ -98,7 +100,7 @@ namespace librocmlite
std::string ModuleRef::to_string() std::string ModuleRef::to_string()
{ {
std::string buf; std::string buf;
raw_string_ostream os(buf); llvm::raw_string_ostream os(buf);
M->print(os, nullptr); M->print(os, nullptr);
os.flush(); os.flush();
return buf; return buf;
...@@ -210,12 +212,12 @@ namespace librocmlite ...@@ -210,12 +212,12 @@ namespace librocmlite
// For codegen passes, only passes that do IR to IR transformation are // For codegen passes, only passes that do IR to IR transformation are
// supported. // supported.
initializeExpandMemCmpPassPass(Registry); initializeExpandMemCmpPassPass(Registry);
initializeScalarizeMaskedMemIntrinPass(Registry); // initializeScalarizeMaskedMemIntrinPass(Registry);
initializeCodeGenPreparePass(Registry); initializeCodeGenPreparePass(Registry);
initializeAtomicExpandPass(Registry); initializeAtomicExpandPass(Registry);
initializeRewriteSymbolsLegacyPassPass(Registry); initializeRewriteSymbolsLegacyPassPass(Registry);
initializeWinEHPreparePass(Registry); initializeWinEHPreparePass(Registry);
initializeDwarfEHPreparePass(Registry); // initializeDwarfEHPreparePass(Registry);
initializeSafeStackLegacyPassPass(Registry); initializeSafeStackLegacyPassPass(Registry);
initializeSjLjEHPreparePass(Registry); initializeSjLjEHPreparePass(Registry);
initializePreISelIntrinsicLoweringLegacyPassPass(Registry); initializePreISelIntrinsicLoweringLegacyPassPass(Registry);
...@@ -295,7 +297,7 @@ namespace librocmlite ...@@ -295,7 +297,7 @@ namespace librocmlite
{ {
Builder.Inliner = createAlwaysInlinerLegacyPass(); Builder.Inliner = createAlwaysInlinerLegacyPass();
} }
Builder.DisableUnitAtATime = !UnitAtATime; // Builder.DisableUnitAtATime = !UnitAtATime;
Builder.DisableUnrollLoops = OptLevel == 0; Builder.DisableUnrollLoops = OptLevel == 0;
// This is final, unless there is a #pragma vectorize enable // This is final, unless there is a #pragma vectorize enable
...@@ -347,7 +349,7 @@ namespace librocmlite ...@@ -347,7 +349,7 @@ namespace librocmlite
return TheTarget->createTargetMachine(TheTriple.getTriple(), return TheTarget->createTargetMachine(TheTriple.getTriple(),
CPUStr, FeaturesStr, Options, CPUStr, FeaturesStr, Options,
getRelocModel(), getCodeModel(), llvm::codegen::getExplicitRelocModel(), llvm::codegen::getExplicitCodeModel(),
GetCodeGenOptLevel(OptLevel)); GetCodeGenOptLevel(OptLevel));
} }
...@@ -393,7 +395,7 @@ namespace librocmlite ...@@ -393,7 +395,7 @@ namespace librocmlite
} }
M->setTargetTriple(Triple::normalize("amdgcn--amdhsa")); M->setTargetTriple(Triple::normalize("amdgcn-amd-amdhsa"));
Triple ModuleTriple(M->getTargetTriple()); Triple ModuleTriple(M->getTargetTriple());
...@@ -411,7 +413,7 @@ namespace librocmlite ...@@ -411,7 +413,7 @@ namespace librocmlite
// Override function attributes based on CPUStr, FeaturesStr, and command line // Override function attributes based on CPUStr, FeaturesStr, and command line
// flags. // flags.
setFunctionAttributes(CPUStr, FeaturesStr, *M); llvm::codegen::setFunctionAttributes(CPUStr, FeaturesStr, *M);
// Create a PassManager to hold and optimize the collection of passes we are // Create a PassManager to hold and optimize the collection of passes we are
// about to build. // about to build.
...@@ -483,7 +485,7 @@ namespace librocmlite ...@@ -483,7 +485,7 @@ namespace librocmlite
// --- START LLC section --- // --- START LLC section ---
int CompileModule(std::unique_ptr<Module> mod, raw_string_ostream &os, bool emitBRIG, int CompileModule(std::unique_ptr<Module> mod, llvm::raw_string_ostream &os, bool emitBRIG,
int OptLevel, const char * Cpu) int OptLevel, const char * Cpu)
{ {
// Load the module to be compiled... // Load the module to be compiled...
...@@ -491,7 +493,7 @@ namespace librocmlite ...@@ -491,7 +493,7 @@ namespace librocmlite
Triple TheTriple;// = Triple(mod->getTargetTriple()); Triple TheTriple;// = Triple(mod->getTargetTriple());
TheTriple = Triple(Triple::normalize("amdgcn--amdhsa")); TheTriple = Triple(Triple::normalize("amdgcn-amd-amdhsa"));
// Get the target specific parser. // Get the target specific parser.
std::string Error; std::string Error;
...@@ -506,7 +508,8 @@ namespace librocmlite ...@@ -506,7 +508,8 @@ namespace librocmlite
// Package up features to be passed to target/subtarget // Package up features to be passed to target/subtarget
std::string CPUStr(Cpu); std::string CPUStr(Cpu);
std::string FeaturesStr = "+promote-alloca,+fp64-denormals,+flat-for-global,"; // std::string FeaturesStr = "+promote-alloca,+fp64-denormals,+flat-for-global,";
std::string FeaturesStr = "+promote-alloca,+flat-for-global,";
CodeGenOpt::Level OLvl = CodeGenOpt::Default; CodeGenOpt::Level OLvl = CodeGenOpt::Default;
switch (OptLevel) switch (OptLevel)
...@@ -525,20 +528,20 @@ namespace librocmlite ...@@ -525,20 +528,20 @@ namespace librocmlite
break; break;
} }
TargetOptions Options = InitTargetOptionsFromCodeGenFlags(); TargetOptions Options = llvm::codegen::InitTargetOptionsFromCodeGenFlags(Triple());
Options.MCOptions.AsmVerbose = true; Options.MCOptions.AsmVerbose = true;
std::unique_ptr<TargetMachine> Target( std::unique_ptr<TargetMachine> Target(
TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr, FeaturesStr, TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr, FeaturesStr,
Options, getRelocModel(), getCodeModel(), Options, llvm::codegen::getExplicitRelocModel(), llvm::codegen::getExplicitCodeModel(),
OLvl)); OLvl));
assert(Target && "Could not allocate target machine!"); assert(Target && "Could not allocate target machine!");
assert(mod && "Should have exited if we didn't have a module!"); assert(mod && "Should have exited if we didn't have a module!");
if (FloatABIForCalls != FloatABI::Default) // if (FloatABIForCalls != FloatABI::Default)
Options.FloatABIType = FloatABIForCalls; // Options.FloatABIType = FloatABIForCalls;
// Build up all of the passes that we want to do to the module. // Build up all of the passes that we want to do to the module.
legacy::PassManager PM; legacy::PassManager PM;
...@@ -554,11 +557,11 @@ namespace librocmlite ...@@ -554,11 +557,11 @@ namespace librocmlite
// Add the target data from the target machine, if it exists, or the module./ // Add the target data from the target machine, if it exists, or the module./
mod->setDataLayout(Target->createDataLayout()); mod->setDataLayout(Target->createDataLayout());
setFunctionAttributes(CPUStr, FeaturesStr, *mod); llvm::codegen::setFunctionAttributes(CPUStr, FeaturesStr, *mod);
auto FileType = (emitBRIG auto FileType = (emitBRIG
? TargetMachine::CGFT_ObjectFile ? CGFT_ObjectFile
: TargetMachine::CGFT_AssemblyFile); : CGFT_AssemblyFile);
{ {
// new scope // new scope
...@@ -566,7 +569,8 @@ namespace librocmlite ...@@ -566,7 +569,8 @@ namespace librocmlite
// Ask the target to add backend passes as necessary. // Ask the target to add backend passes as necessary.
bool Verify = true; bool Verify = true;
if (Target->addPassesToEmitFile(PM, BOS, FileType, Verify)) if (Target->addPassesToEmitFile(PM, BOS, nullptr, FileType, Verify, nullptr))
// if (Target->addPassesToEmitFile(PM, BOS, FileType, Verify))
{ {
errs() << "target does not support generation of this" errs() << "target does not support generation of this"
<< " file type!\n"; << " file type!\n";
...@@ -668,7 +672,7 @@ extern "C" { ...@@ -668,7 +672,7 @@ extern "C" {
if (OptLevel < 0 || OptLevel > 3) return 0; if (OptLevel < 0 || OptLevel > 3) return 0;
// Compile // Compile
std::string buf; std::string buf;
raw_string_ostream os(buf); llvm::raw_string_ostream os(buf);
int status = CompileModule(std::move(sM), os, false, OptLevel, Cpu); int status = CompileModule(std::move(sM), os, false, OptLevel, Cpu);
if(status) return 0; if(status) return 0;
// Write output // Write output
...@@ -686,7 +690,7 @@ extern "C" { ...@@ -686,7 +690,7 @@ extern "C" {
if (OptLevel < 0 || OptLevel > 3) return 0; if (OptLevel < 0 || OptLevel > 3) return 0;
// Compile // Compile
std::string buf; std::string buf;
raw_string_ostream os(buf); llvm::raw_string_ostream os(buf);
int status = CompileModule(std::move(sM), os, true, OptLevel, Cpu); int status = CompileModule(std::move(sM), os, true, OptLevel, Cpu);
if(status) return 0; if(status) return 0;
// Write output // Write output
......
; ModuleID = 'copy_kernel_1d' ; ModuleID = 'copy_kernel_1d'
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n32" target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7"
target triple = "amdgcn--amdhsa" target triple = "amdgcn-amd-amdhsa"
define internal spir_func i32 @hsapy_devfn__5F__5F_main_5F__5F__2E_copy_5F_kernel_5F_1d_24_1_2E_array_28_float32_2C__20_1d_2C__20_C_29__2E_array_28_float32_2C__20_1d_2C__20_C_29_(i8** %.ret, i8* %arg.out.0, i8* %arg.out.1, i64 %arg.out.2, i64 %arg.out.3, float addrspace(4)* %arg.out.4, i64 %arg.out.5.0, i64 %arg.out.6.0, i8* %arg.inp.0, i8* %arg.inp.1, i64 %arg.inp.2, i64 %arg.inp.3, float addrspace(4)* %arg.inp.4, i64 %arg.inp.5.0, i64 %arg.inp.6.0) { define internal spir_func i32 @hsapy_devfn__5F__5F_main_5F__5F__2E_copy_5F_kernel_5F_1d_24_1_2E_array_28_float32_2C__20_1d_2C__20_C_29__2E_array_28_float32_2C__20_1d_2C__20_C_29_(i8** %.ret, i8* %arg.out.0, i8* %arg.out.1, i64 %arg.out.2, i64 %arg.out.3, float addrspace(4)* %arg.out.4, i64 %arg.out.5.0, i64 %arg.out.6.0, i8* %arg.inp.0, i8* %arg.inp.1, i64 %arg.inp.2, i64 %arg.inp.3, float addrspace(4)* %arg.inp.4, i64 %arg.inp.5.0, i64 %arg.inp.6.0) {
entry: entry:
......
...@@ -51,15 +51,14 @@ std::string read_bc_from_file(const char * filename) ...@@ -51,15 +51,14 @@ std::string read_bc_from_file(const char * filename)
// the names of the bitcode files that need linking in // the names of the bitcode files that need linking in
std::vector<std::string> _bitcodes = { \ std::vector<std::string> _bitcodes = { \
"opencl.amdgcn.bc", \ "opencl.bc", \
"ocml.amdgcn.bc", \ "ocml.bc", \
"ockl.amdgcn.bc", \ "ockl.bc", \
"oclc_correctly_rounded_sqrt_off.amdgcn.bc", \ "oclc_correctly_rounded_sqrt_off.bc", \
"oclc_daz_opt_off.amdgcn.bc", \ "oclc_daz_opt_off.bc", \
"oclc_finite_only_off.amdgcn.bc", \ "oclc_finite_only_off.bc", \
"oclc_isa_version_803.amdgcn.bc", \ "oclc_isa_version_906.bc", \
"oclc_unsafe_math_off.amdgcn.bc", \ "oclc_unsafe_math_off.bc"
"irif.amdgcn.bc"
}; };
...@@ -103,7 +102,7 @@ TEST(TEST_BASE, test_parse_ir_module) ...@@ -103,7 +102,7 @@ TEST(TEST_BASE, test_parse_ir_module)
// Check the module BC parse works cleanly and can then be destroyed. // Check the module BC parse works cleanly and can then be destroyed.
TEST(TEST_BASE, test_parse_bc_module) TEST(TEST_BASE, test_parse_bc_module)
{ {
std::string bc = read_bc_from_file("opencl.amdgcn.bc"); std::string bc = read_bc_from_file("opencl.bc");
ModuleRef* theRef = ROC_ParseBitcode(bc.c_str(), bc.size()); ModuleRef* theRef = ROC_ParseBitcode(bc.c_str(), bc.size());
ROC_ModuleDestroy(theRef); ROC_ModuleDestroy(theRef);
} }
...@@ -163,7 +162,7 @@ TEST(TEST_BASE, test_optimize_module) ...@@ -163,7 +162,7 @@ TEST(TEST_BASE, test_optimize_module)
} }
// run an optimisation pass over the module // run an optimisation pass over the module
ret = ROC_ModuleOptimize(dst, 3, 0, 1, "fiji"); ret = ROC_ModuleOptimize(dst, 0, 0, 1, "gfx906");
EXPECT_TRUE(ret == 1); EXPECT_TRUE(ret == 1);
ROC_ModuleDestroy(dst); ROC_ModuleDestroy(dst);
...@@ -192,10 +191,10 @@ TEST(TEST_BASE, test_compile_module_to_HSAIL) ...@@ -192,10 +191,10 @@ TEST(TEST_BASE, test_compile_module_to_HSAIL)
ROC_ModuleDestroy(bc_src); ROC_ModuleDestroy(bc_src);
} }
const char * cpu = "fiji"; const char * cpu = "gfx906";
// run an optimisation pass over the module // run an optimisation pass over the module
ret = ROC_ModuleOptimize(dst, 3, 0, 1, cpu); ret = ROC_ModuleOptimize(dst, 0, 0, 1, cpu);
ASSERT_TRUE(ret == 1); ASSERT_TRUE(ret == 1);
char * output; char * output;
...@@ -235,10 +234,10 @@ TEST(TEST_BASE, test_compile_module_to_BRIG) ...@@ -235,10 +234,10 @@ TEST(TEST_BASE, test_compile_module_to_BRIG)
ROC_ModuleDestroy(bc_src); ROC_ModuleDestroy(bc_src);
} }
const char * cpu = "fiji"; const char * cpu = "gfx906";
// run an optimisation pass over the module // run an optimisation pass over the module
ret = ROC_ModuleOptimize(dst, 3, 0, 1, cpu); ret = ROC_ModuleOptimize(dst, 0, 0, 1, cpu);
ASSERT_TRUE(ret == 1); ASSERT_TRUE(ret == 1);
char * output; char * output;
...@@ -259,51 +258,51 @@ TEST(TEST_BASE, test_compile_module_to_BRIG) ...@@ -259,51 +258,51 @@ TEST(TEST_BASE, test_compile_module_to_BRIG)
} }
// Test many compilation calls to BRIG works // Test many compilation calls to BRIG works
TEST(TEST_BASE, test_many_compile_module_to_BRIG) // TEST(TEST_BASE, test_many_compile_module_to_BRIG)
{ // {
const char * cpu = "fiji"; // const char * cpu = "gfx906";
int trials = 5; // int trials = 5;
for(int k = 0; k < trials; k++) // for(int k = 0; k < trials; k++)
{ // {
ROC_Initialize(); // ROC_Initialize();
std::string ir = read_ir_from_file("demo_ir.ll"); // std::string ir = read_ir_from_file("demo_ir.ll");
ModuleRef* dst = ROC_ParseModule(ir.c_str()); // ModuleRef* dst = ROC_ParseModule(ir.c_str());
int ret; // int ret;
for (auto& bitcode : _bitcodes) // for (auto& bitcode : _bitcodes)
{ // {
std::string builtins_bc = read_bc_from_file(bitcode.c_str()); // std::string builtins_bc = read_bc_from_file(bitcode.c_str());
ModuleRef* bc_src = ROC_ParseBitcode(builtins_bc.c_str(), // ModuleRef* bc_src = ROC_ParseBitcode(builtins_bc.c_str(),
builtins_bc.size()); // builtins_bc.size());
// link the builtins into the module // // link the builtins into the module
ret = ROC_ModuleLinkIn(dst, bc_src); // ret = ROC_ModuleLinkIn(dst, bc_src);
EXPECT_TRUE(ret != 0); // EXPECT_TRUE(ret != 0);
ROC_ModuleDestroy(bc_src); // ROC_ModuleDestroy(bc_src);
} // }
// run an optimisation pass over the module // // run an optimisation pass over the module
ret = ROC_ModuleOptimize(dst, 3, 0, 1, cpu); // ret = ROC_ModuleOptimize(dst, 0, 0, 1, cpu);
ASSERT_TRUE(ret == 1); // ASSERT_TRUE(ret == 1);
char * output; // char * output;
ret = ROC_ModuleEmitBRIG(dst, 2, cpu, &output); // ret = ROC_ModuleEmitBRIG(dst, 2, cpu, &output);
EXPECT_TRUE(ret > 0); // EXPECT_TRUE(ret > 0);
char elf_string[] = "\x7f\x45\x4c\x46"; // char elf_string[] = "\x7f\x45\x4c\x46";
// check this is an ELF object // // check this is an ELF object
for (size_t i = 0; i < 4; i++) // for (size_t i = 0; i < 4; i++)
{ // {
EXPECT_TRUE(output[i]==elf_string[i]); // EXPECT_TRUE(output[i]==elf_string[i]);
} // }
free(output); // free(output);
ROC_ModuleDestroy(dst); // ROC_ModuleDestroy(dst);
} // }
} // }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment