Get rid of native types in LLVM module
Code is still somewhat kludgy because we don't have 32-bit enums. Issue #1673
This commit is contained in:
parent
f6f3d518e6
commit
c6aead7281
14 changed files with 247 additions and 265 deletions
|
@ -16,10 +16,7 @@ import option::none;
|
|||
import std::sha1::sha1;
|
||||
import syntax::ast;
|
||||
import syntax::print::pprust;
|
||||
import lib::llvm::llvm::ModuleRef;
|
||||
import lib::llvm::mk_pass_manager;
|
||||
import lib::llvm::mk_target_data;
|
||||
import lib::llvm::False;
|
||||
import lib::llvm::{ModuleRef, mk_pass_manager, mk_target_data, True, False};
|
||||
import util::filesearch;
|
||||
|
||||
enum output_type {
|
||||
|
@ -182,7 +179,7 @@ mod write {
|
|||
let MPMB = llvm::LLVMPassManagerBuilderCreate();
|
||||
llvm::LLVMPassManagerBuilderSetOptLevel(MPMB,
|
||||
opts.optimize as c_uint);
|
||||
llvm::LLVMPassManagerBuilderSetSizeLevel(MPMB, 0);
|
||||
llvm::LLVMPassManagerBuilderSetSizeLevel(MPMB, False);
|
||||
llvm::LLVMPassManagerBuilderSetDisableUnitAtATime(MPMB, False);
|
||||
llvm::LLVMPassManagerBuilderSetDisableUnrollLoops(MPMB, False);
|
||||
llvm::LLVMPassManagerBuilderSetDisableSimplifyLibCalls(MPMB,
|
||||
|
|
|
@ -5,10 +5,7 @@ import middle::trans::common::{T_fn, T_i1, T_i8, T_i32,
|
|||
T_int, T_nil, T_dict,
|
||||
T_opaque_vec, T_ptr,
|
||||
T_size_t, T_void};
|
||||
import lib::llvm::type_names;
|
||||
import lib::llvm::llvm::ModuleRef;
|
||||
import lib::llvm::llvm::ValueRef;
|
||||
import lib::llvm::llvm::TypeRef;
|
||||
import lib::llvm::{type_names, ModuleRef, ValueRef, TypeRef};
|
||||
|
||||
type upcalls =
|
||||
{_fail: ValueRef,
|
||||
|
|
|
@ -1,144 +1,149 @@
|
|||
import core::{vec, str, option};
|
||||
import str::sbuf;
|
||||
|
||||
import llvm::{TypeRef, MemoryBufferRef,
|
||||
PassManagerRef, TargetDataRef,
|
||||
ObjectFileRef, SectionIteratorRef};
|
||||
import ctypes::{c_int, c_uint, unsigned, longlong, ulonglong};
|
||||
|
||||
type Long = i32;
|
||||
type Bool = int;
|
||||
|
||||
|
||||
const True: Bool = 1;
|
||||
const False: Bool = 0;
|
||||
type Opcode = u32;
|
||||
type Bool = unsigned;
|
||||
const True: Bool = 1u32;
|
||||
const False: Bool = 0u32;
|
||||
|
||||
// Consts for the LLVM CallConv type, pre-cast to uint.
|
||||
// FIXME: figure out a way to merge these with the native
|
||||
// typedef and/or a enum type in the native module below.
|
||||
|
||||
const LLVMCCallConv: uint = 0u;
|
||||
const LLVMFastCallConv: uint = 8u;
|
||||
const LLVMColdCallConv: uint = 9u;
|
||||
const LLVMX86StdcallCallConv: uint = 64u;
|
||||
const LLVMX86FastcallCallConv: uint = 65u;
|
||||
enum CallConv {
|
||||
CCallConv = 0,
|
||||
FastCallConv = 8,
|
||||
ColdCallConv = 9,
|
||||
X86StdcallCallConv = 64,
|
||||
X86FastcallCallConv = 65,
|
||||
}
|
||||
|
||||
const LLVMDefaultVisibility: uint = 0u;
|
||||
const LLVMHiddenVisibility: uint = 1u;
|
||||
const LLVMProtectedVisibility: uint = 2u;
|
||||
enum Visibility {
|
||||
LLVMDefaultVisibility = 0,
|
||||
HiddenVisibility = 1,
|
||||
ProtectedVisibility = 2,
|
||||
}
|
||||
|
||||
const LLVMExternalLinkage: uint = 0u;
|
||||
const LLVMAvailableExternallyLinkage: uint = 1u;
|
||||
const LLVMLinkOnceAnyLinkage: uint = 2u;
|
||||
const LLVMLinkOnceODRLinkage: uint = 3u;
|
||||
const LLVMWeakAnyLinkage: uint = 4u;
|
||||
const LLVMWeakODRLinkage: uint = 5u;
|
||||
const LLVMAppendingLinkage: uint = 6u;
|
||||
const LLVMInternalLinkage: uint = 7u;
|
||||
const LLVMPrivateLinkage: uint = 8u;
|
||||
const LLVMDLLImportLinkage: uint = 9u;
|
||||
const LLVMDLLExportLinkage: uint = 10u;
|
||||
const LLVMExternalWeakLinkage: uint = 11u;
|
||||
const LLVMGhostLinkage: uint = 12u;
|
||||
const LLVMCommonLinkage: uint = 13u;
|
||||
const LLVMLinkerPrivateLinkage: uint = 14u;
|
||||
const LLVMLinkerPrivateWeakLinkage: uint = 15u;
|
||||
const LLVMLinkerPrivateWeakDefAutoLinkage: uint = 16u;
|
||||
|
||||
const LLVMZExtAttribute: uint = 1u;
|
||||
const LLVMSExtAttribute: uint = 2u;
|
||||
const LLVMNoReturnAttribute: uint = 4u;
|
||||
const LLVMInRegAttribute: uint = 8u;
|
||||
const LLVMStructRetAttribute: uint = 16u;
|
||||
const LLVMNoUnwindAttribute: uint = 32u;
|
||||
const LLVMNoAliasAttribute: uint = 64u;
|
||||
const LLVMByValAttribute: uint = 128u;
|
||||
const LLVMNestAttribute: uint = 256u;
|
||||
const LLVMReadNoneAttribute: uint = 512u;
|
||||
const LLVMReadOnlyAttribute: uint = 1024u;
|
||||
const LLVMNoInlineAttribute: uint = 2048u;
|
||||
const LLVMAlwaysInlineAttribute: uint = 4096u;
|
||||
const LLVMOptimizeForSizeAttribute: uint = 8192u;
|
||||
const LLVMStackProtectAttribute: uint = 16384u;
|
||||
const LLVMStackProtectReqAttribute: uint = 32768u;
|
||||
// 31 << 16
|
||||
const LLVMAlignmentAttribute: uint = 2031616u;
|
||||
const LLVMNoCaptureAttribute: uint = 2097152u;
|
||||
const LLVMNoRedZoneAttribute: uint = 4194304u;
|
||||
const LLVMNoImplicitFloatAttribute: uint = 8388608u;
|
||||
const LLVMNakedAttribute: uint = 16777216u;
|
||||
const LLVMInlineHintAttribute: uint = 33554432u;
|
||||
// 7 << 26
|
||||
const LLVMStackAttribute: uint = 469762048u;
|
||||
const LLVMReturnsTwiceAttribute: uint = 536870912u;
|
||||
// 1 << 30
|
||||
const LLVMUWTableAttribute: uint = 1073741824u;
|
||||
const LLVMNonLazyBindAttribute: uint = 2147483648u;
|
||||
enum Linkage {
|
||||
ExternalLinkage = 0,
|
||||
AvailableExternallyLinkage = 1,
|
||||
LinkOnceAnyLinkage = 2,
|
||||
LinkOnceODRLinkage = 3,
|
||||
WeakAnyLinkage = 4,
|
||||
WeakODRLinkage = 5,
|
||||
AppendingLinkage = 6,
|
||||
InternalLinkage = 7,
|
||||
PrivateLinkage = 8,
|
||||
DLLImportLinkage = 9,
|
||||
DLLExportLinkage = 10,
|
||||
ExternalWeakLinkage = 11,
|
||||
GhostLinkage = 12,
|
||||
CommonLinkage = 13,
|
||||
LinkerPrivateLinkage = 14,
|
||||
LinkerPrivateWeakLinkage = 15,
|
||||
LinkerPrivateWeakDefAutoLinkage = 16,
|
||||
}
|
||||
|
||||
enum Attribute {
|
||||
ZExtAttribute = 1,
|
||||
SExtAttribute = 2,
|
||||
NoReturnAttribute = 4,
|
||||
InRegAttribute = 8,
|
||||
StructRetAttribute = 16,
|
||||
NoUnwindAttribute = 32,
|
||||
NoAliasAttribute = 64,
|
||||
ByValAttribute = 128,
|
||||
NestAttribute = 256,
|
||||
ReadNoneAttribute = 512,
|
||||
ReadOnlyAttribute = 1024,
|
||||
NoInlineAttribute = 2048,
|
||||
AlwaysInlineAttribute = 4096,
|
||||
OptimizeForSizeAttribute = 8192,
|
||||
StackProtectAttribute = 16384,
|
||||
StackProtectReqAttribute = 32768,
|
||||
// 31 << 16
|
||||
AlignmentAttribute = 2031616,
|
||||
NoCaptureAttribute = 2097152,
|
||||
NoRedZoneAttribute = 4194304,
|
||||
NoImplicitFloatAttribute = 8388608,
|
||||
NakedAttribute = 16777216,
|
||||
InlineHintAttribute = 33554432,
|
||||
// 7 << 26
|
||||
StackAttribute = 469762048,
|
||||
ReturnsTwiceAttribute = 536870912,
|
||||
// 1 << 30
|
||||
UWTableAttribute = 1073741824,
|
||||
NonLazyBindAttribute = 2147483648,
|
||||
}
|
||||
|
||||
// Consts for the LLVM IntPredicate type, pre-cast to uint.
|
||||
// FIXME: as above.
|
||||
|
||||
|
||||
const LLVMIntEQ: uint = 32u;
|
||||
const LLVMIntNE: uint = 33u;
|
||||
const LLVMIntUGT: uint = 34u;
|
||||
const LLVMIntUGE: uint = 35u;
|
||||
const LLVMIntULT: uint = 36u;
|
||||
const LLVMIntULE: uint = 37u;
|
||||
const LLVMIntSGT: uint = 38u;
|
||||
const LLVMIntSGE: uint = 39u;
|
||||
const LLVMIntSLT: uint = 40u;
|
||||
const LLVMIntSLE: uint = 41u;
|
||||
|
||||
enum IntPredicate {
|
||||
IntEQ = 32,
|
||||
IntNE = 33,
|
||||
IntUGT = 34,
|
||||
IntUGE = 35,
|
||||
IntULT = 36,
|
||||
IntULE = 37,
|
||||
IntSGT = 38,
|
||||
IntSGE = 39,
|
||||
IntSLT = 40,
|
||||
IntSLE = 41,
|
||||
}
|
||||
|
||||
// Consts for the LLVM RealPredicate type, pre-case to uint.
|
||||
// FIXME: as above.
|
||||
|
||||
const LLVMRealOEQ: uint = 1u;
|
||||
const LLVMRealOGT: uint = 2u;
|
||||
const LLVMRealOGE: uint = 3u;
|
||||
const LLVMRealOLT: uint = 4u;
|
||||
const LLVMRealOLE: uint = 5u;
|
||||
const LLVMRealONE: uint = 6u;
|
||||
enum RealPredicate {
|
||||
RealOEQ = 1,
|
||||
RealOGT = 2,
|
||||
RealOGE = 3,
|
||||
RealOLT = 4,
|
||||
RealOLE = 5,
|
||||
RealONE = 6,
|
||||
RealORD = 7,
|
||||
RealUNO = 8,
|
||||
RealUEQ = 9,
|
||||
RealUGT = 10,
|
||||
RealUGE = 11,
|
||||
RealULT = 12,
|
||||
RealULE = 13,
|
||||
RealUNE = 14,
|
||||
}
|
||||
|
||||
const LLVMRealORD: uint = 7u;
|
||||
const LLVMRealUNO: uint = 8u;
|
||||
const LLVMRealUEQ: uint = 9u;
|
||||
const LLVMRealUGT: uint = 10u;
|
||||
const LLVMRealUGE: uint = 11u;
|
||||
const LLVMRealULT: uint = 12u;
|
||||
const LLVMRealULE: uint = 13u;
|
||||
const LLVMRealUNE: uint = 14u;
|
||||
// Opaque pointer types
|
||||
enum Module_opaque {}
|
||||
type ModuleRef = *Module_opaque;
|
||||
enum Context_opaque {}
|
||||
type ContextRef = *Context_opaque;
|
||||
enum Type_opaque {}
|
||||
type TypeRef = *Type_opaque;
|
||||
enum Value_opaque {}
|
||||
type ValueRef = *Value_opaque;
|
||||
enum BasicBlock_opaque {}
|
||||
type BasicBlockRef = *BasicBlock_opaque;
|
||||
enum Builder_opaque {}
|
||||
type BuilderRef = *Builder_opaque;
|
||||
enum MemoryBuffer_opaque {}
|
||||
type MemoryBufferRef = *MemoryBuffer_opaque;
|
||||
enum PassManager_opaque {}
|
||||
type PassManagerRef = *PassManager_opaque;
|
||||
enum PassManagerBuilder_opaque {}
|
||||
type PassManagerBuilderRef = *PassManagerBuilder_opaque;
|
||||
enum Use_opaque {}
|
||||
type UseRef = *Use_opaque;
|
||||
enum TargetData_opaque {}
|
||||
type TargetDataRef = *TargetData_opaque;
|
||||
enum ObjectFile_opaque {}
|
||||
type ObjectFileRef = *ObjectFile_opaque;
|
||||
enum SectionIterator_opaque {}
|
||||
type SectionIteratorRef = *SectionIterator_opaque;
|
||||
|
||||
#[link_args = "-Lrustllvm"]
|
||||
#[link_name = "rustllvm"]
|
||||
#[abi = "cdecl"]
|
||||
native mod llvm {
|
||||
|
||||
type ModuleRef;
|
||||
type ContextRef;
|
||||
type TypeRef;
|
||||
type TypeHandleRef;
|
||||
type ValueRef;
|
||||
type BasicBlockRef;
|
||||
type BuilderRef;
|
||||
type ModuleProviderRef;
|
||||
type MemoryBufferRef;
|
||||
type PassManagerRef;
|
||||
type PassManagerBuilderRef;
|
||||
type UseRef;
|
||||
type TargetDataRef;
|
||||
|
||||
/* FIXME: These are enums in the C header. Represent them how, in rust? */
|
||||
type Linkage;
|
||||
type Attribute;
|
||||
type Visibility;
|
||||
type CallConv;
|
||||
type IntPredicate;
|
||||
type RealPredicate;
|
||||
type Opcode;
|
||||
|
||||
/* Create and destroy contexts. */
|
||||
fn LLVMContextCreate() -> ContextRef;
|
||||
fn LLVMGetGlobalContext() -> ContextRef;
|
||||
|
@ -422,12 +427,12 @@ native mod llvm {
|
|||
/* Operations on global variables, functions, and aliases (globals) */
|
||||
fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
|
||||
fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
|
||||
fn LLVMGetLinkage(Global: ValueRef) -> Linkage;
|
||||
fn LLVMSetLinkage(Global: ValueRef, Link: Linkage);
|
||||
fn LLVMGetLinkage(Global: ValueRef) -> unsigned;
|
||||
fn LLVMSetLinkage(Global: ValueRef, Link: unsigned);
|
||||
fn LLVMGetSection(Global: ValueRef) -> sbuf;
|
||||
fn LLVMSetSection(Global: ValueRef, Section: sbuf);
|
||||
fn LLVMGetVisibility(Global: ValueRef) -> Visibility;
|
||||
fn LLVMSetVisibility(Global: ValueRef, Viz: Visibility);
|
||||
fn LLVMGetVisibility(Global: ValueRef) -> unsigned;
|
||||
fn LLVMSetVisibility(Global: ValueRef, Viz: unsigned);
|
||||
fn LLVMGetAlignment(Global: ValueRef) -> unsigned;
|
||||
fn LLVMSetAlignment(Global: ValueRef, Bytes: unsigned);
|
||||
|
||||
|
@ -469,9 +474,9 @@ native mod llvm {
|
|||
fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: unsigned);
|
||||
fn LLVMGetGC(Fn: ValueRef) -> sbuf;
|
||||
fn LLVMSetGC(Fn: ValueRef, Name: sbuf);
|
||||
fn LLVMAddFunctionAttr(Fn: ValueRef, PA: Attribute, HighPA: unsigned);
|
||||
fn LLVMGetFunctionAttr(Fn: ValueRef) -> Attribute;
|
||||
fn LLVMRemoveFunctionAttr(Fn: ValueRef, PA: Attribute, HighPA: unsigned);
|
||||
fn LLVMAddFunctionAttr(Fn: ValueRef, PA: unsigned, HighPA: unsigned);
|
||||
fn LLVMGetFunctionAttr(Fn: ValueRef) -> unsigned;
|
||||
fn LLVMRemoveFunctionAttr(Fn: ValueRef, PA: unsigned, HighPA: unsigned);
|
||||
|
||||
/* Operations on parameters */
|
||||
fn LLVMCountParams(Fn: ValueRef) -> unsigned;
|
||||
|
@ -482,9 +487,9 @@ native mod llvm {
|
|||
fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
|
||||
fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
|
||||
fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
|
||||
fn LLVMAddAttribute(Arg: ValueRef, PA: Attribute);
|
||||
fn LLVMRemoveAttribute(Arg: ValueRef, PA: Attribute);
|
||||
fn LLVMGetAttribute(Arg: ValueRef) -> Attribute;
|
||||
fn LLVMAddAttribute(Arg: ValueRef, PA: unsigned);
|
||||
fn LLVMRemoveAttribute(Arg: ValueRef, PA: unsigned);
|
||||
fn LLVMGetAttribute(Arg: ValueRef) -> unsigned;
|
||||
fn LLVMSetParamAlignment(Arg: ValueRef, align: unsigned);
|
||||
|
||||
/* Operations on basic blocks */
|
||||
|
@ -520,9 +525,9 @@ native mod llvm {
|
|||
/* Operations on call sites */
|
||||
fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: unsigned);
|
||||
fn LLVMGetInstructionCallConv(Instr: ValueRef) -> unsigned;
|
||||
fn LLVMAddInstrAttribute(Instr: ValueRef, index: unsigned, IA: Attribute);
|
||||
fn LLVMAddInstrAttribute(Instr: ValueRef, index: unsigned, IA: unsigned);
|
||||
fn LLVMRemoveInstrAttribute(Instr: ValueRef, index: unsigned,
|
||||
IA: Attribute);
|
||||
IA: unsigned);
|
||||
fn LLVMSetInstrParamAlignment(Instr: ValueRef, index: unsigned,
|
||||
align: unsigned);
|
||||
|
||||
|
@ -836,9 +841,6 @@ native mod llvm {
|
|||
|
||||
/* Stuff that's in rustllvm/ because it's not upstream yet. */
|
||||
|
||||
type ObjectFileRef;
|
||||
type SectionIteratorRef;
|
||||
|
||||
/** Opens an object file. */
|
||||
fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
|
||||
/** Closes an object file. */
|
||||
|
@ -907,6 +909,16 @@ native mod llvm {
|
|||
fn LLVMLinkModules(Dest: ModuleRef, Src: ModuleRef) -> Bool;
|
||||
}
|
||||
|
||||
fn SetInstructionCallConv(Instr: ValueRef, CC: CallConv) {
|
||||
llvm::LLVMSetInstructionCallConv(Instr, CC as unsigned);
|
||||
}
|
||||
fn SetFunctionCallConv(Fn: ValueRef, CC: CallConv) {
|
||||
llvm::LLVMSetFunctionCallConv(Fn, CC as unsigned);
|
||||
}
|
||||
fn SetLinkage(Global: ValueRef, Link: Linkage) {
|
||||
llvm::LLVMSetLinkage(Global, Link as unsigned);
|
||||
}
|
||||
|
||||
/* Memory-managed object interface to type handles. */
|
||||
|
||||
type type_names = @{type_names: std::map::hashmap<TypeRef, str>,
|
||||
|
|
|
@ -2,7 +2,7 @@ import core::{vec, str, option, sys, ctypes, unsafe};
|
|||
import std::fs;
|
||||
import std::map::hashmap;
|
||||
import lib::llvm::llvm;
|
||||
import lib::llvm::llvm::ValueRef;
|
||||
import lib::llvm::ValueRef;
|
||||
import trans::common::*;
|
||||
import trans::base;
|
||||
import trans::build::B;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Routines useful for garbage collection.
|
||||
|
||||
import lib::llvm::True;
|
||||
import lib::llvm::llvm::ValueRef;
|
||||
import lib::llvm::{True, ValueRef};
|
||||
import trans::base::get_tydesc;
|
||||
import trans::common::*;
|
||||
import trans::base;
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
// This substitutes for the runtime tags used by e.g. MLs.
|
||||
|
||||
import lib::llvm::llvm;
|
||||
import lib::llvm::{True, False};
|
||||
import lib::llvm::llvm::{ModuleRef, TypeRef, ValueRef};
|
||||
import lib::llvm::{True, False, ModuleRef, TypeRef, ValueRef};
|
||||
import driver::session;
|
||||
import driver::session::session;
|
||||
import trans::base;
|
||||
|
@ -97,9 +96,7 @@ fn mk_global(ccx: @crate_ctxt, name: str, llval: ValueRef, internal: bool) ->
|
|||
lib::llvm::llvm::LLVMSetGlobalConstant(llglobal, True);
|
||||
|
||||
if internal {
|
||||
lib::llvm::llvm::LLVMSetLinkage(llglobal,
|
||||
lib::llvm::LLVMInternalLinkage as
|
||||
lib::llvm::llvm::Linkage);
|
||||
lib::llvm::SetLinkage(llglobal, lib::llvm::InternalLinkage);
|
||||
}
|
||||
|
||||
ret llglobal;
|
||||
|
@ -606,9 +603,8 @@ fn gen_shape_tables(ccx: @crate_ctxt) {
|
|||
[lltagstable, llresourcestable]);
|
||||
lib::llvm::llvm::LLVMSetInitializer(ccx.shape_cx.llshapetables, lltables);
|
||||
lib::llvm::llvm::LLVMSetGlobalConstant(ccx.shape_cx.llshapetables, True);
|
||||
lib::llvm::llvm::LLVMSetLinkage(ccx.shape_cx.llshapetables,
|
||||
lib::llvm::LLVMInternalLinkage as
|
||||
lib::llvm::llvm::Linkage);
|
||||
lib::llvm::SetLinkage(ccx.shape_cx.llshapetables,
|
||||
lib::llvm::InternalLinkage);
|
||||
}
|
||||
|
||||
// ______________________________________________________________________
|
||||
|
|
|
@ -3,7 +3,7 @@ import option::{some, none};
|
|||
|
||||
import driver::session::session;
|
||||
import lib::llvm::llvm;
|
||||
import lib::llvm::llvm::{ValueRef, BasicBlockRef};
|
||||
import lib::llvm::{ValueRef, BasicBlockRef};
|
||||
import pat_util::*;
|
||||
import build::*;
|
||||
import base::{new_sub_block_ctxt, new_scope_block_ctxt,
|
||||
|
|
|
@ -32,7 +32,7 @@ import pat_util::*;
|
|||
import visit::vt;
|
||||
import util::common::*;
|
||||
import lib::llvm::{llvm, mk_target_data, mk_type_names};
|
||||
import lib::llvm::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef};
|
||||
import lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef};
|
||||
import lib::llvm::{True, False};
|
||||
import link::{mangle_internal_name_by_type_only,
|
||||
mangle_internal_name_by_seq,
|
||||
|
@ -288,17 +288,17 @@ fn log_fn_time(ccx: @crate_ctxt, name: str, start: time::timeval,
|
|||
}
|
||||
|
||||
|
||||
fn decl_fn(llmod: ModuleRef, name: str, cc: uint, llty: TypeRef) ->
|
||||
ValueRef {
|
||||
let llfn: ValueRef =
|
||||
str::as_buf(name, {|buf|
|
||||
llvm::LLVMGetOrInsertFunction(llmod, buf, llty) });
|
||||
llvm::LLVMSetFunctionCallConv(llfn, cc as c_uint);
|
||||
fn decl_fn(llmod: ModuleRef, name: str, cc: lib::llvm::CallConv,
|
||||
llty: TypeRef) -> ValueRef {
|
||||
let llfn: ValueRef = str::as_buf(name, {|buf|
|
||||
llvm::LLVMGetOrInsertFunction(llmod, buf, llty)
|
||||
});
|
||||
lib::llvm::SetFunctionCallConv(llfn, cc);
|
||||
ret llfn;
|
||||
}
|
||||
|
||||
fn decl_cdecl_fn(llmod: ModuleRef, name: str, llty: TypeRef) -> ValueRef {
|
||||
ret decl_fn(llmod, name, lib::llvm::LLVMCCallConv, llty);
|
||||
ret decl_fn(llmod, name, lib::llvm::CCallConv, llty);
|
||||
}
|
||||
|
||||
|
||||
|
@ -307,13 +307,12 @@ fn decl_cdecl_fn(llmod: ModuleRef, name: str, llty: TypeRef) -> ValueRef {
|
|||
fn decl_internal_cdecl_fn(llmod: ModuleRef, name: str, llty: TypeRef) ->
|
||||
ValueRef {
|
||||
let llfn = decl_cdecl_fn(llmod, name, llty);
|
||||
llvm::LLVMSetLinkage(llfn,
|
||||
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
|
||||
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
|
||||
ret llfn;
|
||||
}
|
||||
|
||||
fn get_extern_fn(externs: hashmap<str, ValueRef>, llmod: ModuleRef, name: str,
|
||||
cc: uint, ty: TypeRef) -> ValueRef {
|
||||
cc: lib::llvm::CallConv, ty: TypeRef) -> ValueRef {
|
||||
if externs.contains_key(name) { ret externs.get(name); }
|
||||
let f = decl_fn(llmod, name, cc, ty);
|
||||
externs.insert(name, f);
|
||||
|
@ -336,8 +335,7 @@ fn get_simple_extern_fn(cx: @block_ctxt,
|
|||
let inputs = vec::init_elt::<TypeRef>(n_args as uint, ccx.int_type);
|
||||
let output = ccx.int_type;
|
||||
let t = T_fn(inputs, output);
|
||||
ret get_extern_fn(externs, llmod, name,
|
||||
lib::llvm::LLVMCCallConv, t);
|
||||
ret get_extern_fn(externs, llmod, name, lib::llvm::CCallConv, t);
|
||||
}
|
||||
|
||||
fn trans_native_call(cx: @block_ctxt, externs: hashmap<str, ValueRef>,
|
||||
|
@ -370,12 +368,12 @@ fn trans_shared_free(cx: @block_ctxt, v: ValueRef) -> @block_ctxt {
|
|||
}
|
||||
|
||||
fn umax(cx: @block_ctxt, a: ValueRef, b: ValueRef) -> ValueRef {
|
||||
let cond = ICmp(cx, lib::llvm::LLVMIntULT, a, b);
|
||||
let cond = ICmp(cx, lib::llvm::IntULT, a, b);
|
||||
ret Select(cx, cond, b, a);
|
||||
}
|
||||
|
||||
fn umin(cx: @block_ctxt, a: ValueRef, b: ValueRef) -> ValueRef {
|
||||
let cond = ICmp(cx, lib::llvm::LLVMIntULT, a, b);
|
||||
let cond = ICmp(cx, lib::llvm::IntULT, a, b);
|
||||
ret Select(cx, cond, a, b);
|
||||
}
|
||||
|
||||
|
@ -992,32 +990,25 @@ fn get_static_tydesc(cx: @block_ctxt, t: ty::t, ty_params: [uint])
|
|||
}
|
||||
|
||||
fn set_no_inline(f: ValueRef) {
|
||||
llvm::LLVMAddFunctionAttr(f,
|
||||
lib::llvm::LLVMNoInlineAttribute as
|
||||
lib::llvm::llvm::Attribute,
|
||||
llvm::LLVMAddFunctionAttr(f, lib::llvm::NoInlineAttribute as c_uint,
|
||||
0u as c_uint);
|
||||
}
|
||||
|
||||
// Tell LLVM to emit the information necessary to unwind the stack for the
|
||||
// function f.
|
||||
fn set_uwtable(f: ValueRef) {
|
||||
llvm::LLVMAddFunctionAttr(f,
|
||||
lib::llvm::LLVMUWTableAttribute as
|
||||
lib::llvm::llvm::Attribute,
|
||||
llvm::LLVMAddFunctionAttr(f, lib::llvm::UWTableAttribute as c_uint,
|
||||
0u as c_uint);
|
||||
}
|
||||
|
||||
fn set_always_inline(f: ValueRef) {
|
||||
llvm::LLVMAddFunctionAttr(f,
|
||||
lib::llvm::LLVMAlwaysInlineAttribute as
|
||||
lib::llvm::llvm::Attribute,
|
||||
llvm::LLVMAddFunctionAttr(f, lib::llvm::AlwaysInlineAttribute as c_uint,
|
||||
0u as c_uint);
|
||||
}
|
||||
|
||||
fn set_custom_stack_growth_fn(f: ValueRef) {
|
||||
// TODO: Remove this hack to work around the lack of u64 in the FFI.
|
||||
llvm::LLVMAddFunctionAttr(f, 0 as lib::llvm::llvm::Attribute,
|
||||
1u as c_uint);
|
||||
llvm::LLVMAddFunctionAttr(f, 0u as c_uint, 1u as c_uint);
|
||||
}
|
||||
|
||||
fn set_glue_inlining(cx: @local_ctxt, f: ValueRef, t: ty::t) {
|
||||
|
@ -1089,8 +1080,7 @@ fn make_generic_glue_inner(cx: @local_ctxt, t: ty::t,
|
|||
llfn: ValueRef, helper: glue_helper,
|
||||
ty_params: [uint]) -> ValueRef {
|
||||
let fcx = new_fn_ctxt(cx, llfn, none);
|
||||
llvm::LLVMSetLinkage(llfn,
|
||||
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
|
||||
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
|
||||
cx.ccx.stats.n_glues_created += 1u;
|
||||
// Any nontrivial glue is with values passed *by alias*; this is a
|
||||
// requirement since in many contexts glue is invoked indirectly and
|
||||
|
@ -1193,8 +1183,7 @@ fn emit_tydescs(ccx: @crate_ctxt) {
|
|||
let gvar = ti.tydesc;
|
||||
llvm::LLVMSetInitializer(gvar, tydesc);
|
||||
llvm::LLVMSetGlobalConstant(gvar, True);
|
||||
llvm::LLVMSetLinkage(gvar,
|
||||
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
|
||||
lib::llvm::SetLinkage(gvar, lib::llvm::InternalLinkage);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1402,7 +1391,7 @@ fn decr_refcnt_maybe_free(cx: @block_ctxt, box_ptr: ValueRef, t: ty::t)
|
|||
let rc = Load(rc_adj_cx, rc_ptr);
|
||||
rc = Sub(rc_adj_cx, rc, C_int(ccx, 1));
|
||||
Store(rc_adj_cx, rc, rc_ptr);
|
||||
let zero_test = ICmp(rc_adj_cx, lib::llvm::LLVMIntEQ, C_int(ccx, 0), rc);
|
||||
let zero_test = ICmp(rc_adj_cx, lib::llvm::IntEQ, C_int(ccx, 0), rc);
|
||||
CondBr(rc_adj_cx, zero_test, free_cx.llbb, next_cx.llbb);
|
||||
let free_cx = free_ty(free_cx, box_ptr, t);
|
||||
Br(free_cx, next_cx.llbb);
|
||||
|
@ -1472,36 +1461,36 @@ fn compare_scalar_values(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef,
|
|||
}
|
||||
floating_point {
|
||||
let cmp = alt op {
|
||||
ast::eq { lib::llvm::LLVMRealOEQ }
|
||||
ast::ne { lib::llvm::LLVMRealUNE }
|
||||
ast::lt { lib::llvm::LLVMRealOLT }
|
||||
ast::le { lib::llvm::LLVMRealOLE }
|
||||
ast::gt { lib::llvm::LLVMRealOGT }
|
||||
ast::ge { lib::llvm::LLVMRealOGE }
|
||||
ast::eq { lib::llvm::RealOEQ }
|
||||
ast::ne { lib::llvm::RealUNE }
|
||||
ast::lt { lib::llvm::RealOLT }
|
||||
ast::le { lib::llvm::RealOLE }
|
||||
ast::gt { lib::llvm::RealOGT }
|
||||
ast::ge { lib::llvm::RealOGE }
|
||||
_ { die(); }
|
||||
};
|
||||
ret FCmp(cx, cmp, lhs, rhs);
|
||||
}
|
||||
signed_int {
|
||||
let cmp = alt op {
|
||||
ast::eq { lib::llvm::LLVMIntEQ }
|
||||
ast::ne { lib::llvm::LLVMIntNE }
|
||||
ast::lt { lib::llvm::LLVMIntSLT }
|
||||
ast::le { lib::llvm::LLVMIntSLE }
|
||||
ast::gt { lib::llvm::LLVMIntSGT }
|
||||
ast::ge { lib::llvm::LLVMIntSGE }
|
||||
ast::eq { lib::llvm::IntEQ }
|
||||
ast::ne { lib::llvm::IntNE }
|
||||
ast::lt { lib::llvm::IntSLT }
|
||||
ast::le { lib::llvm::IntSLE }
|
||||
ast::gt { lib::llvm::IntSGT }
|
||||
ast::ge { lib::llvm::IntSGE }
|
||||
_ { die(); }
|
||||
};
|
||||
ret ICmp(cx, cmp, lhs, rhs);
|
||||
}
|
||||
unsigned_int {
|
||||
let cmp = alt op {
|
||||
ast::eq { lib::llvm::LLVMIntEQ }
|
||||
ast::ne { lib::llvm::LLVMIntNE }
|
||||
ast::lt { lib::llvm::LLVMIntULT }
|
||||
ast::le { lib::llvm::LLVMIntULE }
|
||||
ast::gt { lib::llvm::LLVMIntUGT }
|
||||
ast::ge { lib::llvm::LLVMIntUGE }
|
||||
ast::eq { lib::llvm::IntEQ }
|
||||
ast::ne { lib::llvm::IntNE }
|
||||
ast::lt { lib::llvm::IntULT }
|
||||
ast::le { lib::llvm::IntULE }
|
||||
ast::gt { lib::llvm::IntUGT }
|
||||
ast::ge { lib::llvm::IntUGE }
|
||||
_ { die(); }
|
||||
};
|
||||
ret ICmp(cx, cmp, lhs, rhs);
|
||||
|
@ -1920,7 +1909,7 @@ fn copy_val(cx: @block_ctxt, action: copy_action, dst: ValueRef,
|
|||
let next_cx = new_sub_block_ctxt(cx, "next");
|
||||
let dstcmp = load_if_immediate(cx, dst, t);
|
||||
let self_assigning =
|
||||
ICmp(cx, lib::llvm::LLVMIntNE,
|
||||
ICmp(cx, lib::llvm::IntNE,
|
||||
PointerCast(cx, dstcmp, val_ty(src)), src);
|
||||
CondBr(cx, self_assigning, do_copy_cx.llbb, next_cx.llbb);
|
||||
do_copy_cx = copy_val_no_check(do_copy_cx, action, dst, src, t);
|
||||
|
@ -2598,13 +2587,10 @@ fn lookup_discriminant(lcx: @local_ctxt, vid: ast::def_id) -> ValueRef {
|
|||
// It's an external discriminant that we haven't seen yet.
|
||||
assert (vid.crate != ast::local_crate);
|
||||
let sym = csearch::get_symbol(lcx.ccx.sess.cstore, vid);
|
||||
let gvar =
|
||||
str::as_buf(sym,
|
||||
{|buf|
|
||||
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf)
|
||||
});
|
||||
llvm::LLVMSetLinkage(gvar,
|
||||
lib::llvm::LLVMExternalLinkage as llvm::Linkage);
|
||||
let gvar = str::as_buf(sym, {|buf|
|
||||
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf)
|
||||
});
|
||||
lib::llvm::SetLinkage(gvar, lib::llvm::ExternalLinkage);
|
||||
llvm::LLVMSetGlobalConstant(gvar, True);
|
||||
lcx.ccx.discrims.insert(vid, gvar);
|
||||
ret gvar;
|
||||
|
@ -2739,7 +2725,7 @@ fn trans_index(cx: @block_ctxt, ex: @ast::expr, base: @ast::expr,
|
|||
maybe_name_value(bcx_ccx(cx), scaled_ix, "scaled_ix");
|
||||
let lim = tvec::get_fill(bcx, v);
|
||||
let body = tvec::get_dataptr(bcx, v, type_of_or_i8(bcx, unit_ty));
|
||||
let bounds_check = ICmp(bcx, lib::llvm::LLVMIntULT, scaled_ix, lim);
|
||||
let bounds_check = ICmp(bcx, lib::llvm::IntULT, scaled_ix, lim);
|
||||
let fail_cx = new_sub_block_ctxt(bcx, "fail");
|
||||
let next_cx = new_sub_block_ctxt(bcx, "next");
|
||||
let ncx = bcx_ccx(next_cx);
|
||||
|
@ -3760,8 +3746,7 @@ fn trans_log(lvl: @ast::expr, cx: @block_ctxt, e: @ast::expr) -> @block_ctxt {
|
|||
});
|
||||
llvm::LLVMSetGlobalConstant(global, False);
|
||||
llvm::LLVMSetInitializer(global, C_null(T_i32()));
|
||||
llvm::LLVMSetLinkage(global,
|
||||
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
|
||||
lib::llvm::SetLinkage(global, lib::llvm::InternalLinkage);
|
||||
lcx.ccx.module_data.insert(modname, global);
|
||||
global
|
||||
};
|
||||
|
@ -3772,7 +3757,7 @@ fn trans_log(lvl: @ast::expr, cx: @block_ctxt, e: @ast::expr) -> @block_ctxt {
|
|||
|
||||
Br(cx, level_cx.llbb);
|
||||
let level_res = trans_temp_expr(level_cx, lvl);
|
||||
let test = ICmp(level_res.bcx, lib::llvm::LLVMIntUGE,
|
||||
let test = ICmp(level_res.bcx, lib::llvm::IntUGE,
|
||||
load, level_res.val);
|
||||
|
||||
CondBr(level_res.bcx, test, log_cx.llbb, after_cx.llbb);
|
||||
|
@ -4834,7 +4819,7 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
|
|||
fn build_shim_fn(lcx: @local_ctxt,
|
||||
native_item: @ast::native_item,
|
||||
tys: @c_stack_tys,
|
||||
cc: uint) -> ValueRef {
|
||||
cc: lib::llvm::CallConv) -> ValueRef {
|
||||
let lname = link_name(native_item);
|
||||
let ccx = lcx_ccx(lcx);
|
||||
|
||||
|
@ -4861,7 +4846,7 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
|
|||
|
||||
// Create the call itself and store the return value:
|
||||
let llretval = CallWithConv(bcx, llbasefn,
|
||||
llargvals, cc as c_uint); // r
|
||||
llargvals, cc); // r
|
||||
if tys.ret_def {
|
||||
// R** llretptr = &args->r;
|
||||
let llretptr = GEPi(bcx, llargbundle, [0, n as int]);
|
||||
|
@ -4911,11 +4896,11 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
|
|||
}
|
||||
|
||||
let ccx = lcx_ccx(lcx);
|
||||
let cc = lib::llvm::LLVMCCallConv;
|
||||
let cc = lib::llvm::CCallConv;
|
||||
alt abi {
|
||||
ast::native_abi_rust_intrinsic { ret; }
|
||||
ast::native_abi_cdecl { cc = lib::llvm::LLVMCCallConv; }
|
||||
ast::native_abi_stdcall { cc = lib::llvm::LLVMX86StdcallCallConv; }
|
||||
ast::native_abi_cdecl { cc = lib::llvm::CCallConv; }
|
||||
ast::native_abi_stdcall { cc = lib::llvm::X86StdcallCallConv; }
|
||||
}
|
||||
|
||||
for native_item in native_mod.items {
|
||||
|
@ -5076,7 +5061,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
|
|||
let nt = ty::mk_nil(ccx.tcx);
|
||||
let llfty = type_of_fn(ccx, [vecarg_ty], nt, []);
|
||||
let llfdecl = decl_fn(ccx.llmod, "_rust_main",
|
||||
lib::llvm::LLVMCCallConv, llfty);
|
||||
lib::llvm::CCallConv, llfty);
|
||||
|
||||
let fcx = new_fn_ctxt(new_local_ctxt(ccx), llfdecl, none);
|
||||
|
||||
|
@ -5230,7 +5215,7 @@ fn collect_native_item(ccx: @crate_ctxt,
|
|||
let ri_name = "rust_intrinsic_" + link_name(i);
|
||||
let llnativefn = get_extern_fn(
|
||||
ccx.externs, ccx.llmod, ri_name,
|
||||
lib::llvm::LLVMCCallConv, fn_type);
|
||||
lib::llvm::CCallConv, fn_type);
|
||||
ccx.item_ids.insert(id, llnativefn);
|
||||
ccx.item_symbols.insert(id, ri_name);
|
||||
}
|
||||
|
@ -5433,11 +5418,10 @@ fn trap(bcx: @block_ctxt) {
|
|||
fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
|
||||
let elttype = T_struct([ccx.int_type, ccx.int_type]);
|
||||
let maptype = T_array(elttype, ccx.module_data.size() + 1u);
|
||||
let map =
|
||||
str::as_buf("_rust_mod_map",
|
||||
{|buf| llvm::LLVMAddGlobal(ccx.llmod, maptype, buf) });
|
||||
llvm::LLVMSetLinkage(map,
|
||||
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
|
||||
let map = str::as_buf("_rust_mod_map", {|buf|
|
||||
llvm::LLVMAddGlobal(ccx.llmod, maptype, buf)
|
||||
});
|
||||
lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage);
|
||||
let elts: [ValueRef] = [];
|
||||
ccx.module_data.items {|key, val|
|
||||
let elt = C_struct([p2i(ccx, C_cstr(ccx, key)),
|
||||
|
@ -5465,8 +5449,7 @@ fn decl_crate_map(sess: session::session, mapname: str,
|
|||
let map = str::as_buf(sym_name, {|buf|
|
||||
llvm::LLVMAddGlobal(llmod, maptype, buf)
|
||||
});
|
||||
llvm::LLVMSetLinkage(map, lib::llvm::LLVMExternalLinkage
|
||||
as llvm::Linkage);
|
||||
lib::llvm::SetLinkage(map, lib::llvm::ExternalLinkage);
|
||||
ret map;
|
||||
}
|
||||
|
||||
|
@ -5500,19 +5483,14 @@ fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) {
|
|||
str::as_buf(cx.sess.targ_cfg.target_strs.meta_sect_name, {|buf|
|
||||
llvm::LLVMSetSection(llglobal, buf)
|
||||
});
|
||||
llvm::LLVMSetLinkage(llglobal,
|
||||
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
|
||||
lib::llvm::SetLinkage(llglobal, lib::llvm::InternalLinkage);
|
||||
|
||||
let t_ptr_i8 = T_ptr(T_i8());
|
||||
llglobal = llvm::LLVMConstBitCast(llglobal, t_ptr_i8);
|
||||
let llvm_used =
|
||||
str::as_buf("llvm.used",
|
||||
{|buf|
|
||||
llvm::LLVMAddGlobal(cx.llmod, T_array(t_ptr_i8, 1u),
|
||||
buf)
|
||||
});
|
||||
llvm::LLVMSetLinkage(llvm_used,
|
||||
lib::llvm::LLVMAppendingLinkage as llvm::Linkage);
|
||||
let llvm_used = str::as_buf("llvm.used", {|buf|
|
||||
llvm::LLVMAddGlobal(cx.llmod, T_array(t_ptr_i8, 1u), buf)
|
||||
});
|
||||
lib::llvm::SetLinkage(llvm_used, lib::llvm::AppendingLinkage);
|
||||
llvm::LLVMSetInitializer(llvm_used, C_array(t_ptr_i8, [llglobal]));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,9 @@ import str::sbuf;
|
|||
import lib::llvm::llvm;
|
||||
import syntax::codemap;
|
||||
import codemap::span;
|
||||
import llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, Opcode,
|
||||
ModuleRef};
|
||||
import lib::llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, ModuleRef};
|
||||
import lib::llvm::{Opcode, IntPredicate, RealPredicate, True, False,
|
||||
CallConv};
|
||||
import common::{block_ctxt, T_ptr, T_nil, T_i8, T_i1, T_void,
|
||||
T_fn, val_ty, bcx_ccx, C_i32};
|
||||
|
||||
|
@ -110,8 +111,7 @@ fn FastInvoke(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef],
|
|||
let v = llvm::LLVMBuildInvoke(B(cx), Fn, vec::to_ptr(Args),
|
||||
vec::len(Args) as c_uint,
|
||||
Then, Catch, noname());
|
||||
llvm::LLVMSetInstructionCallConv(
|
||||
v, lib::llvm::LLVMFastCallConv as c_uint);
|
||||
lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -467,12 +467,14 @@ fn FPCast(cx: @block_ctxt, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
|
|||
|
||||
|
||||
/* Comparisons */
|
||||
fn ICmp(cx: @block_ctxt, Op: uint, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||
fn ICmp(cx: @block_ctxt, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef)
|
||||
-> ValueRef {
|
||||
if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); }
|
||||
ret llvm::LLVMBuildICmp(B(cx), Op as c_uint, LHS, RHS, noname());
|
||||
}
|
||||
|
||||
fn FCmp(cx: @block_ctxt, Op: uint, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
|
||||
fn FCmp(cx: @block_ctxt, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef)
|
||||
-> ValueRef {
|
||||
if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); }
|
||||
ret llvm::LLVMBuildFCmp(B(cx), Op as c_uint, LHS, RHS, noname());
|
||||
}
|
||||
|
@ -528,9 +530,12 @@ fn add_comment(bcx: @block_ctxt, text: str) {
|
|||
check str::is_not_empty("$");
|
||||
let sanitized = str::replace(text, "$", "");
|
||||
let comment_text = "; " + sanitized;
|
||||
let asm = str::as_buf(comment_text, { |c|
|
||||
str::as_buf("", { |e|
|
||||
llvm::LLVMConstInlineAsm(T_fn([], T_void()), c, e, 0, 0)})});
|
||||
let asm = str::as_buf(comment_text, {|c|
|
||||
str::as_buf("", {|e|
|
||||
llvm::LLVMConstInlineAsm(T_fn([], T_void()), c, e,
|
||||
False, False)
|
||||
})
|
||||
});
|
||||
Call(bcx, asm, []);
|
||||
}
|
||||
}
|
||||
|
@ -548,19 +553,18 @@ fn FastCall(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef]) -> ValueRef {
|
|||
unsafe {
|
||||
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
|
||||
vec::len(Args) as c_uint, noname());
|
||||
llvm::LLVMSetInstructionCallConv(
|
||||
v, lib::llvm::LLVMFastCallConv as c_uint);
|
||||
lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv);
|
||||
ret v;
|
||||
}
|
||||
}
|
||||
|
||||
fn CallWithConv(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef],
|
||||
Conv: c_uint) -> ValueRef {
|
||||
Conv: CallConv) -> ValueRef {
|
||||
if cx.unreachable { ret _UndefReturn(cx, Fn); }
|
||||
unsafe {
|
||||
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
|
||||
vec::len(Args) as c_uint, noname());
|
||||
llvm::LLVMSetInstructionCallConv(v, Conv);
|
||||
lib::llvm::SetInstructionCallConv(v, Conv);
|
||||
ret v;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import core::ctypes::c_uint;
|
|||
import syntax::ast;
|
||||
import syntax::ast_util;
|
||||
import lib::llvm::llvm;
|
||||
import llvm::{ValueRef, TypeRef};
|
||||
import lib::llvm::{ValueRef, TypeRef};
|
||||
import common::*;
|
||||
import build::*;
|
||||
import base::*;
|
||||
|
|
|
@ -17,7 +17,7 @@ import util::common::*;
|
|||
import syntax::codemap::span;
|
||||
import lib::llvm::{llvm, target_data, type_names, associate_type,
|
||||
name_has_type};
|
||||
import lib::llvm::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef};
|
||||
import lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef, BuilderRef};
|
||||
import lib::llvm::{True, False, Bool};
|
||||
import metadata::{csearch};
|
||||
|
||||
|
@ -72,7 +72,7 @@ type stats =
|
|||
mutable n_real_glues: uint,
|
||||
fn_times: @mutable [{ident: str, time: int}]};
|
||||
|
||||
resource BuilderRef_res(B: llvm::BuilderRef) { llvm::LLVMDisposeBuilder(B); }
|
||||
resource BuilderRef_res(B: BuilderRef) { llvm::LLVMDisposeBuilder(B); }
|
||||
|
||||
// Crate context. Every crate we compile has one of these.
|
||||
type crate_ctxt =
|
||||
|
@ -788,7 +788,7 @@ fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef {
|
|||
{|buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf) });
|
||||
llvm::LLVMSetInitializer(g, sc);
|
||||
llvm::LLVMSetGlobalConstant(g, True);
|
||||
llvm::LLVMSetLinkage(g, lib::llvm::LLVMInternalLinkage as llvm::Linkage);
|
||||
lib::llvm::SetLinkage(g, lib::llvm::InternalLinkage);
|
||||
ret g;
|
||||
}
|
||||
|
||||
|
@ -835,8 +835,7 @@ fn C_shape(ccx: @crate_ctxt, bytes: [u8]) -> ValueRef {
|
|||
});
|
||||
llvm::LLVMSetInitializer(llglobal, llshape);
|
||||
llvm::LLVMSetGlobalConstant(llglobal, True);
|
||||
llvm::LLVMSetLinkage(llglobal,
|
||||
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
|
||||
lib::llvm::SetLinkage(llglobal, lib::llvm::InternalLinkage);
|
||||
ret llvm::LLVMConstPointerCast(llglobal, T_ptr(T_i8()));
|
||||
}
|
||||
|
||||
|
@ -894,12 +893,12 @@ fn hash_dict_id(&&dp: dict_id) -> uint {
|
|||
}
|
||||
|
||||
fn umax(cx: @block_ctxt, a: ValueRef, b: ValueRef) -> ValueRef {
|
||||
let cond = build::ICmp(cx, lib::llvm::LLVMIntULT, a, b);
|
||||
let cond = build::ICmp(cx, lib::llvm::IntULT, a, b);
|
||||
ret build::Select(cx, cond, b, a);
|
||||
}
|
||||
|
||||
fn umin(cx: @block_ctxt, a: ValueRef, b: ValueRef) -> ValueRef {
|
||||
let cond = build::ICmp(cx, lib::llvm::LLVMIntULT, a, b);
|
||||
let cond = build::ICmp(cx, lib::llvm::IntULT, a, b);
|
||||
ret build::Select(cx, cond, a, b);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ import syntax::{ast, ast_util};
|
|||
import metadata::csearch;
|
||||
import back::{link, abi};
|
||||
import lib::llvm::llvm;
|
||||
import llvm::{ValueRef, TypeRef, LLVMGetParam};
|
||||
import lib::llvm::{ValueRef, TypeRef};
|
||||
import lib::llvm::llvm::LLVMGetParam;
|
||||
|
||||
// Translation functionality related to impls and ifaces
|
||||
//
|
||||
|
@ -384,8 +385,7 @@ fn get_static_dict(bcx: @block_ctxt, origin: typeck::dict_origin)
|
|||
});
|
||||
llvm::LLVMSetGlobalConstant(gvar, lib::llvm::True);
|
||||
llvm::LLVMSetInitializer(gvar, ptrs);
|
||||
llvm::LLVMSetLinkage(gvar,
|
||||
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
|
||||
lib::llvm::SetLinkage(gvar, lib::llvm::InternalLinkage);
|
||||
let cast = llvm::LLVMConstPointerCast(gvar, T_ptr(T_dict()));
|
||||
ccx.dicts.insert(id, cast);
|
||||
cast
|
||||
|
|
|
@ -2,7 +2,7 @@ import vec;
|
|||
import option::none;
|
||||
import syntax::ast;
|
||||
import driver::session::session;
|
||||
import lib::llvm::llvm::{ValueRef, TypeRef};
|
||||
import lib::llvm::{ValueRef, TypeRef};
|
||||
import back::abi;
|
||||
import base::{call_memmove, trans_shared_malloc, type_of_or_i8,
|
||||
INIT, copy_val, load_if_immediate, get_tydesc,
|
||||
|
@ -170,7 +170,7 @@ fn trans_append(cx: @block_ctxt, vec_ty: ty::t, lhsptr: ValueRef,
|
|||
let llunitty = type_of_or_i8(cx, unit_ty);
|
||||
|
||||
let lhs = Load(bcx, lhsptr);
|
||||
let self_append = ICmp(bcx, lib::llvm::LLVMIntEQ, lhs, rhs);
|
||||
let self_append = ICmp(bcx, lib::llvm::IntEQ, lhs, rhs);
|
||||
let lfill = get_fill(bcx, lhs);
|
||||
let rfill = get_fill(bcx, rhs);
|
||||
let new_fill = Add(bcx, lfill, rfill);
|
||||
|
@ -295,7 +295,7 @@ fn iter_vec_raw(bcx: @block_ctxt, vptr: ValueRef, vec_ty: ty::t,
|
|||
Br(bcx, header_cx.llbb);
|
||||
let data_ptr = Phi(header_cx, val_ty(data_ptr), [data_ptr], [bcx.llbb]);
|
||||
let not_yet_at_end =
|
||||
ICmp(header_cx, lib::llvm::LLVMIntULT, data_ptr, data_end_ptr);
|
||||
ICmp(header_cx, lib::llvm::IntULT, data_ptr, data_end_ptr);
|
||||
let body_cx = new_sub_block_ctxt(header_cx, "iter_vec_loop_body");
|
||||
let next_cx = new_sub_block_ctxt(header_cx, "iter_vec_next");
|
||||
CondBr(header_cx, not_yet_at_end, body_cx.llbb, next_cx.llbb);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import syntax::ast;
|
||||
import lib::llvm::llvm::ValueRef;
|
||||
import lib::llvm::ValueRef;
|
||||
import common::*;
|
||||
import build::*;
|
||||
import base::{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue