Skip to content

Commit

Permalink
blah
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusaa committed Dec 15, 2023
1 parent 0203fec commit beb541c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions clambcc/clambc-compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def createInputSourceFile(clangLLVM: ClangLLVM, name: str, args: list, options:
, 'verify'
, 'clambc-extend-phis-to-64-bit'
, 'verify'
, 'clambc-convert-intrinsics'
, 'clambc-convert-memsets-to-32Bit'
, 'verify'
, 'globalopt'
, 'clambc-prepare-geps-for-writer'
Expand Down Expand Up @@ -611,7 +611,7 @@ def createInputSourceFile(clangLLVM: ClangLLVM, name: str, args: list, options:
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libclambcoutlineendiannesscalls.so"
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libclambcchangemallocargsize.so"
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libclambcextendphisto64bit.so"
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libclambcconvertintrinsics.so"
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libclambcconvertmemsetsto32bit.so"
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libclambcpreparegepsforwriter.so"
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libclambcanalyzer.so"
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libclambcregalloc.so"
Expand Down Expand Up @@ -707,7 +707,7 @@ def optimize(clangLLVM: ClangLLVM, inFile: str, outFile: str, sigFile: str, inpu
#otherwise the writer gets
#unhappy.
f' -globalopt'
f' -clambc-convert-intrinsics' #convert all memset intrinsics to
f' -clambc-convert-memsets-to-32Bit' #convert all memset intrinsics to
#the 32-bit instead of the 64-bit
#intrinsic
f' -clambc-writer' #write the bytecode
Expand Down
2 changes: 1 addition & 1 deletion libclambcc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ add_subdirectory(ClamBCExtendPHIsTo64Bit)
add_subdirectory(ClamBCRebuild)
add_subdirectory(ClamBCRegAlloc)
#add_subdirectory(ClamBCTypeAnalyzer)
add_subdirectory(ClamBCConvertIntrinsics)
add_subdirectory(ClamBCConvertMemsetsTo32Bit)
add_subdirectory(ClamBCPrepareGEPsForWriter)
add_subdirectory(ClamBCRemoveICMPSLE)
#add_subdirectory(ClamBCRemoveUMIN)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
# Copyright (C) 2021 Cisco Systems, Inc. and/or its affiliates. All rights reserved.

#
# The clambcconvertintrinsics object library
# The clambcconvertmemsetsto32bit object library
#
add_library(clambcconvertintrinsics_obj OBJECT)
target_sources(clambcconvertintrinsics_obj
add_library(clambcconvertmemsetsto32bit_obj OBJECT)
target_sources(clambcconvertmemsetsto32bit_obj
PRIVATE
ClamBCConvertIntrinsics.cpp
ClamBCConvertMemsetsTo32Bit.cpp
)

target_include_directories(clambcconvertintrinsics_obj
target_include_directories(clambcconvertmemsetsto32bit_obj
PRIVATE
${CMAKE_BINARY_DIR} # For clambc-version.h (generated file)
. # For Common/clambc.h
.. # For clambc.h #TODO: change all passes to use "Common" and then delete this line.
${LLVM_INCLUDE_DIRS}
)

set_target_properties(clambcconvertintrinsics_obj PROPERTIES COMPILE_FLAGS "${WARNCXXFLAGS}")
set_target_properties(clambcconvertmemsetsto32bit_obj PROPERTIES COMPILE_FLAGS "${WARNCXXFLAGS}")

#
# For testing
#
#target_compile_definitions(clambcconvertintrinsics_obj -DLOG_BEFORE_AFTER=1)
#target_compile_definitions(clambcconvertmemsetsto32bit_obj -DLOG_BEFORE_AFTER=1)

#
# The clambcconvertintrinsics shared library.
# The clambcconvertmemsetsto32bit shared library.
#
add_library( clambcconvertintrinsics SHARED )
target_link_libraries( clambcconvertintrinsics
add_library( clambcconvertmemsetsto32bit SHARED )
target_link_libraries( clambcconvertmemsetsto32bit
PUBLIC
clambcconvertintrinsics_obj )
set_target_properties( clambcconvertintrinsics PROPERTIES
clambcconvertmemsetsto32bit_obj )
set_target_properties( clambcconvertmemsetsto32bit PROPERTIES
VERSION ${LIBCLAMBC_VERSION}
SOVERSION ${LIBCLAMBC_SOVERSION} )

target_link_directories(clambcconvertintrinsics PRIVATE ${LLVM_LIBRARY_DIRS})
target_link_libraries(clambcconvertintrinsics PUBLIC ${LLVM_LIBS})
target_link_directories(clambcconvertmemsetsto32bit PRIVATE ${LLVM_LIBRARY_DIRS})
target_link_libraries(clambcconvertmemsetsto32bit PUBLIC ${LLVM_LIBS})

if(WIN32)
install(TARGETS clambcconvertintrinsics DESTINATION .)
install(TARGETS clambcconvertmemsetsto32bit DESTINATION .)

# Also install shared library (DLL) dependencies
install(CODE [[
file(GET_RUNTIME_DEPENDENCIES
LIBRARIES
$<TARGET_FILE:clambcconvertintrinsics>
$<TARGET_FILE:clambcconvertmemsetsto32bit>
RESOLVED_DEPENDENCIES_VAR _r_deps
UNRESOLVED_DEPENDENCIES_VAR _u_deps
DIRECTORIES
Expand All @@ -65,7 +65,7 @@ if(WIN32)
#message("UNRESOLVED_DEPENDENCIES_VAR: ${_u_deps}")
]])
else()
install(TARGETS clambcconvertintrinsics DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS clambcconvertmemsetsto32bit DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@

using namespace llvm;

namespace ClamBCConvertIntrinsics {
namespace ClamBCConvertMemsetsTo32Bit {

class ClamBCConvertIntrinsics : public PassInfoMixin<ClamBCConvertIntrinsics >
class ClamBCConvertMemsetsTo32Bit : public PassInfoMixin<ClamBCConvertMemsetsTo32Bit >
{

public:
static char ID;

ClamBCConvertIntrinsics() {}
ClamBCConvertMemsetsTo32Bit() {}

virtual ~ClamBCConvertIntrinsics() {}
virtual ~ClamBCConvertMemsetsTo32Bit() {}

PreservedAnalyses run(Module & mod, ModuleAnalysisManager & MAM)
{
Expand Down Expand Up @@ -95,7 +95,7 @@ class ClamBCConvertIntrinsics : public PassInfoMixin<ClamBCConvertIntrinsics >
if (ConstantInt* ci = llvm::dyn_cast<ConstantInt>(pv)) {
pv = ConstantInt::get(i32Ty, ci->getValue().getLimitedValue());
} else {
pv = CastInst::CreateTruncOrBitCast(pv, i32Ty, "ClamBCConvertIntrinsics_trunc_", pci);
pv = CastInst::CreateTruncOrBitCast(pv, i32Ty, "ClamBCConvertMemsetsTo32Bit_trunc_", pci);
}
}

Expand Down Expand Up @@ -126,13 +126,13 @@ class ClamBCConvertIntrinsics : public PassInfoMixin<ClamBCConvertIntrinsics >
extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK
llvmGetPassPluginInfo() {
return {
LLVM_PLUGIN_API_VERSION, "ClamBCConvertIntrinsics", "v0.1",
LLVM_PLUGIN_API_VERSION, "ClamBCConvertMemsetsTo32Bit", "v0.1",
[](PassBuilder &PB) {
PB.registerPipelineParsingCallback(
[](StringRef Name, ModulePassManager &FPM,
ArrayRef<PassBuilder::PipelineElement>) {
if(Name == "clambc-convert-intrinsics"){
FPM.addPass(ClamBCConvertIntrinsics::ClamBCConvertIntrinsics());
if(Name == "clambc-convert-memsets-to-32Bit"){
FPM.addPass(ClamBCConvertMemsetsTo32Bit::ClamBCConvertMemsetsTo32Bit());
return true;
}
return false;
Expand Down

0 comments on commit beb541c

Please sign in to comment.