#include <llvm-c/ExecutionEngine.h>
#include <llvm/IR/DataLayout.h>
#include <llvm/Target/TargetMachine.h>
+#include <llvm/Analysis/TargetTransformInfo.h>
#include <iostream>
#include <cstdlib>
#include <algorithm>
return ::LLVMCodeGenLevelDefault;
}
+unsigned Target_machine::get_biggest_vector_register_bit_width(::LLVMTargetMachineRef tm,
+ ::LLVMValueRef function)
+{
+ auto unwrapped_function = llvm::unwrap<llvm::Function>(function);
+ llvm::FunctionAnalysisManager function_analysis_manager;
+ return unwrap(tm)
+ ->getTargetIRAnalysis()
+ .run(*unwrapped_function, function_analysis_manager)
+ .getRegisterBitWidth(true);
+}
+
void Module::set_target_machine(::LLVMModuleRef module, ::LLVMTargetMachineRef target_machine)
{
::LLVMSetTarget(module, Target_machine::get_target_triple(target_machine).get());
{
return get_code_gen_opt_level(get());
}
+ static unsigned get_biggest_vector_register_bit_width(::LLVMTargetMachineRef tm,
+ ::LLVMValueRef function);
+ unsigned get_biggest_vector_register_bit_width(::LLVMValueRef function) const
+ {
+ return get_biggest_vector_register_bit_width(get(), function);
+ }
};
struct Module_deleter
if(value == 0)
return ::LLVMGetUndef(::LLVMTypeOf(rhs));
if((value & (value - 1)) == 0)
- return ::LLVMBuildAnd(builder, lhs, ::LLVMConstInt(::LLVMTypeOf(rhs), value - 1, false), result_name);
+ return ::LLVMBuildAnd(
+ builder, lhs, ::LLVMConstInt(::LLVMTypeOf(rhs), value - 1, false), result_name);
}
auto srem_result = ::LLVMBuildSRem(builder, lhs, rhs, "");
auto zero_constant = ::LLVMConstInt(::LLVMTypeOf(lhs), 0, false);
set(sources pipeline.cpp)
add_library(vulkan_cpu_pipeline STATIC ${sources})
-target_link_libraries(vulkan_cpu_pipeline vulkan_cpu_spirv_to_llvm vulkan_cpu_json vulkan_cpu_util vulkan_cpu_spirv vulkan_cpu_llvm_wrapper vulkan_cpu_vulkan)
+target_link_libraries(vulkan_cpu_pipeline vulkan_cpu_spirv_to_llvm vulkan_cpu_json vulkan_cpu_util vulkan_cpu_spirv vulkan_cpu_llvm_wrapper vulkan_cpu_vulkan vulkan_cpu_image)
#warning finish implementing module optimizations
{
auto manager = llvm_wrapper::Pass_manager::create_function_pass_manager(module.get());
+ ::LLVMAddAnalysisPasses(target_machine, manager.get());
::LLVMAddPromoteMemoryToRegisterPass(manager.get());
::LLVMAddScalarReplAggregatesPass(manager.get());
::LLVMAddScalarizerPass(manager.get());
}
{
auto manager = llvm_wrapper::Pass_manager::create_module_pass_manager();
+ ::LLVMAddAnalysisPasses(target_machine, manager.get());
::LLVMAddIPSCCPPass(manager.get());
::LLVMAddFunctionInliningPass(manager.get());
::LLVMAddDeadArgEliminationPass(manager.get());
}
{
auto manager = llvm_wrapper::Pass_manager::create_function_pass_manager(module.get());
+ ::LLVMAddAnalysisPasses(target_machine, manager.get());
::LLVMAddCFGSimplificationPass(manager.get());
::LLVMAddPromoteMemoryToRegisterPass(manager.get());
::LLVMAddScalarReplAggregatesPass(manager.get());