forked from tinygo-org/go-llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackports.go
55 lines (40 loc) · 1.66 KB
/
backports.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package llvm
// This file contains functions backported from LLVM master.
// #include "llvm-c/Core.h"
// #include <stdlib.h>
// #include "backports.h"
import "C"
import "unsafe"
// Token type (used by coroutines)
// https://reviews.llvm.org/D47684
const TokenTypeKind TypeKind = C.LLVMTokenTypeKind
func (c Context) TokenType() (t Type) { t.C = C.LLVMTokenTypeInContext(c.C); return }
// Inline assembly
// https://reviews.llvm.org/D46437
type InlineAsmDialect C.LLVMInlineAsmDialect
const (
InlineAsmDialectATT InlineAsmDialect = C.LLVMInlineAsmDialectATT
InlineAsmDialectIntel InlineAsmDialect = C.LLVMInlineAsmDialectIntel
)
func InlineAsm(t Type, asmString, constraints string, hasSideEffects, isAlignStack bool, dialect InlineAsmDialect) (rv Value) {
casm := C.CString(asmString)
defer C.free(unsafe.Pointer(casm))
cconstraints := C.CString(constraints)
defer C.free(unsafe.Pointer(cconstraints))
rv.C = C.LLVMGetInlineAsm(t.C, casm, C.size_t(len(asmString)), cconstraints, C.size_t(len(constraints)), boolToLLVMBool(hasSideEffects), boolToLLVMBool(isAlignStack), C.LLVMInlineAsmDialect(dialect))
return
}
// Coroutine optimization passes
// https://reviews.llvm.org/D51642 (in progress)
func (pmb PassManagerBuilder) AddCoroutinePassesToExtensionPoints() {
C.LLVMPassManagerBuilderAddCoroutinePassesToExtensionPoints_backport(pmb.C);
}
// Erase instruction
// https://reviews.llvm.org/D52694 (in progress)
func (v Value) EraseFromParentAsInstruction() { C.LLVMInstructionEraseFromParent(v.C) }
// Called function from a CallInst
// https://reviews.llvm.org/D52972 (in progress)
func (v Value) CalledValue() (rv Value) {
rv.C = C.LLVMGetCalledValue(v.C)
return
}