diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d19cd0..97bd7ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -90,3 +90,17 @@ jobs: - name: Test default LLVM run: go test -v + test-linux-llvm-17: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install LLVM + run: | + echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main' | sudo tee /etc/apt/sources.list.d/llvm.list + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo apt-get update + sudo apt-get install --no-install-recommends llvm-17-dev + - name: Test LLVM 17 + run: + go test -v -tags=llvm17 diff --git a/backports.h b/backports.h index d5b9a9c..d489267 100644 --- a/backports.h +++ b/backports.h @@ -1,7 +1,6 @@ #include "llvm-c/DebugInfo.h" #include "llvm-c/Types.h" -#include "llvm-c/Transforms/PassManagerBuilder.h" #ifdef __cplusplus extern "C" { diff --git a/ir.go b/ir.go index 687c660..c357aad 100644 --- a/ir.go +++ b/ir.go @@ -980,10 +980,6 @@ func ConstIntCast(v Value, t Type, signed bool) (rv Value) { return } func ConstFPCast(v Value, t Type) (rv Value) { rv.C = C.LLVMConstFPCast(v.C, t.C); return } -func ConstSelect(cond, iftrue, iffalse Value) (rv Value) { - rv.C = C.LLVMConstSelect(cond.C, iftrue.C, iffalse.C) - return -} func ConstExtractElement(vec, i Value) (rv Value) { rv.C = C.LLVMConstExtractElement(vec.C, i.C) return diff --git a/llvm_config_linux_llvm16.go b/llvm_config_linux_llvm16.go index bc37463..b6f1830 100644 --- a/llvm_config_linux_llvm16.go +++ b/llvm_config_linux_llvm16.go @@ -1,4 +1,4 @@ -//go:build !byollvm && linux && !llvm14 && !llvm15 +//go:build !byollvm && linux && !llvm14 && !llvm15 && !llvm17 package llvm diff --git a/llvm_config_linux_llvm17.go b/llvm_config_linux_llvm17.go new file mode 100644 index 0000000..f2951d7 --- /dev/null +++ b/llvm_config_linux_llvm17.go @@ -0,0 +1,10 @@ +//go:build !byollvm && linux && llvm17 + +package llvm + +// #cgo CPPFLAGS: -I/usr/include/llvm-17 -I/usr/include/llvm-c-17 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS +// #cgo CXXFLAGS: -std=c++17 +// #cgo LDFLAGS: -L/usr/lib/llvm-17/lib -lLLVM-17 +import "C" + +type run_build_sh int diff --git a/transforms_ipo.go b/transforms_ipo.go deleted file mode 100644 index 5463847..0000000 --- a/transforms_ipo.go +++ /dev/null @@ -1,38 +0,0 @@ -//===- transforms_ipo.go - Bindings for ipo -------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file defines bindings for the ipo component. -// -//===----------------------------------------------------------------------===// - -package llvm - -/* -#include "llvm-c/Transforms/IPO.h" -*/ -import "C" - -// helpers -func boolToUnsigned(b bool) C.unsigned { - if b { - return 1 - } - return 0 -} - -func (pm PassManager) AddConstantMergePass() { C.LLVMAddConstantMergePass(pm.C) } -func (pm PassManager) AddDeadArgEliminationPass() { C.LLVMAddDeadArgEliminationPass(pm.C) } -func (pm PassManager) AddFunctionAttrsPass() { C.LLVMAddFunctionAttrsPass(pm.C) } -func (pm PassManager) AddFunctionInliningPass() { C.LLVMAddFunctionInliningPass(pm.C) } -func (pm PassManager) AddGlobalDCEPass() { C.LLVMAddGlobalDCEPass(pm.C) } -func (pm PassManager) AddGlobalOptimizerPass() { C.LLVMAddGlobalOptimizerPass(pm.C) } -func (pm PassManager) AddIPSCCPPass() { C.LLVMAddIPSCCPPass(pm.C) } -func (pm PassManager) AddInternalizePass(allButMain bool) { - C.LLVMAddInternalizePass(pm.C, boolToUnsigned(allButMain)) -} -func (pm PassManager) AddStripDeadPrototypesPass() { C.LLVMAddStripDeadPrototypesPass(pm.C) } diff --git a/transforms_pmbuilder.go b/transforms_pmbuilder.go deleted file mode 100644 index 2c902a1..0000000 --- a/transforms_pmbuilder.go +++ /dev/null @@ -1,63 +0,0 @@ -//===- transforms_pmbuilder.go - Bindings for PassManagerBuilder ----------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file defines bindings for the PassManagerBuilder class. -// -//===----------------------------------------------------------------------===// - -package llvm - -/* -#include "llvm-c/Transforms/PassManagerBuilder.h" -*/ -import "C" - -type PassManagerBuilder struct { - C C.LLVMPassManagerBuilderRef -} - -func NewPassManagerBuilder() (pmb PassManagerBuilder) { - pmb.C = C.LLVMPassManagerBuilderCreate() - return -} - -func (pmb PassManagerBuilder) SetOptLevel(level int) { - C.LLVMPassManagerBuilderSetOptLevel(pmb.C, C.uint(level)) -} - -func (pmb PassManagerBuilder) SetSizeLevel(level int) { - C.LLVMPassManagerBuilderSetSizeLevel(pmb.C, C.uint(level)) -} - -func (pmb PassManagerBuilder) Populate(pm PassManager) { - C.LLVMPassManagerBuilderPopulateModulePassManager(pmb.C, pm.C) -} - -func (pmb PassManagerBuilder) PopulateFunc(pm PassManager) { - C.LLVMPassManagerBuilderPopulateFunctionPassManager(pmb.C, pm.C) -} - -func (pmb PassManagerBuilder) Dispose() { - C.LLVMPassManagerBuilderDispose(pmb.C) -} - -func (pmb PassManagerBuilder) SetDisableUnitAtATime(val bool) { - C.LLVMPassManagerBuilderSetDisableUnitAtATime(pmb.C, boolToLLVMBool(val)) -} - -func (pmb PassManagerBuilder) SetDisableUnrollLoops(val bool) { - C.LLVMPassManagerBuilderSetDisableUnrollLoops(pmb.C, boolToLLVMBool(val)) -} - -func (pmb PassManagerBuilder) SetDisableSimplifyLibCalls(val bool) { - C.LLVMPassManagerBuilderSetDisableSimplifyLibCalls(pmb.C, boolToLLVMBool(val)) -} - -func (pmb PassManagerBuilder) UseInlinerWithThreshold(threshold uint) { - C.LLVMPassManagerBuilderUseInlinerWithThreshold(pmb.C, C.uint(threshold)) -} diff --git a/transforms_scalar.go b/transforms_scalar.go deleted file mode 100644 index a6dc02c..0000000 --- a/transforms_scalar.go +++ /dev/null @@ -1,43 +0,0 @@ -//===- transforms_scalar.go - Bindings for scalaropts ---------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file defines bindings for the scalaropts component. -// -//===----------------------------------------------------------------------===// - -package llvm - -/* -#include "llvm-c/Transforms/Scalar.h" -#include "llvm-c/Transforms/Utils.h" -*/ -import "C" - -func (pm PassManager) AddAggressiveDCEPass() { C.LLVMAddAggressiveDCEPass(pm.C) } -func (pm PassManager) AddCFGSimplificationPass() { C.LLVMAddCFGSimplificationPass(pm.C) } -func (pm PassManager) AddDeadStoreEliminationPass() { C.LLVMAddDeadStoreEliminationPass(pm.C) } -func (pm PassManager) AddGVNPass() { C.LLVMAddGVNPass(pm.C) } -func (pm PassManager) AddIndVarSimplifyPass() { C.LLVMAddIndVarSimplifyPass(pm.C) } -func (pm PassManager) AddInstructionCombiningPass() { C.LLVMAddInstructionCombiningPass(pm.C) } -func (pm PassManager) AddJumpThreadingPass() { C.LLVMAddJumpThreadingPass(pm.C) } -func (pm PassManager) AddLICMPass() { C.LLVMAddLICMPass(pm.C) } -func (pm PassManager) AddLoopDeletionPass() { C.LLVMAddLoopDeletionPass(pm.C) } -func (pm PassManager) AddLoopRotatePass() { C.LLVMAddLoopRotatePass(pm.C) } -func (pm PassManager) AddLoopUnrollPass() { C.LLVMAddLoopUnrollPass(pm.C) } -func (pm PassManager) AddMemCpyOptPass() { C.LLVMAddMemCpyOptPass(pm.C) } -func (pm PassManager) AddPromoteMemoryToRegisterPass() { C.LLVMAddPromoteMemoryToRegisterPass(pm.C) } -func (pm PassManager) AddReassociatePass() { C.LLVMAddReassociatePass(pm.C) } -func (pm PassManager) AddSCCPPass() { C.LLVMAddSCCPPass(pm.C) } -func (pm PassManager) AddScalarReplAggregatesPass() { C.LLVMAddScalarReplAggregatesPass(pm.C) } -func (pm PassManager) AddScalarReplAggregatesPassWithThreshold(threshold int) { - C.LLVMAddScalarReplAggregatesPassWithThreshold(pm.C, C.int(threshold)) -} -func (pm PassManager) AddSimplifyLibCallsPass() { C.LLVMAddSimplifyLibCallsPass(pm.C) } -func (pm PassManager) AddTailCallEliminationPass() { C.LLVMAddTailCallEliminationPass(pm.C) } -func (pm PassManager) AddDemoteMemoryToRegisterPass() { C.LLVMAddDemoteMemoryToRegisterPass(pm.C) } -func (pm PassManager) AddVerifierPass() { C.LLVMAddVerifierPass(pm.C) }