Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3e77f2fc
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3e77f2fc
编写于
8月 30, 2018
作者:
D
Denis Merigoux
提交者:
Eduard-Mihai Burtescu
11月 16, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use the method form for CodegenCx everywhere
上级
6c5b990c
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
54 addition
and
55 deletion
+54
-55
src/librustc_codegen_llvm/abi.rs
src/librustc_codegen_llvm/abi.rs
+1
-1
src/librustc_codegen_llvm/asm.rs
src/librustc_codegen_llvm/asm.rs
+1
-1
src/librustc_codegen_llvm/base.rs
src/librustc_codegen_llvm/base.rs
+9
-9
src/librustc_codegen_llvm/builder.rs
src/librustc_codegen_llvm/builder.rs
+3
-3
src/librustc_codegen_llvm/common.rs
src/librustc_codegen_llvm/common.rs
+3
-3
src/librustc_codegen_llvm/debuginfo/gdb.rs
src/librustc_codegen_llvm/debuginfo/gdb.rs
+2
-2
src/librustc_codegen_llvm/glue.rs
src/librustc_codegen_llvm/glue.rs
+4
-5
src/librustc_codegen_llvm/interfaces/backend.rs
src/librustc_codegen_llvm/interfaces/backend.rs
+3
-1
src/librustc_codegen_llvm/interfaces/builder.rs
src/librustc_codegen_llvm/interfaces/builder.rs
+2
-2
src/librustc_codegen_llvm/interfaces/common.rs
src/librustc_codegen_llvm/interfaces/common.rs
+4
-3
src/librustc_codegen_llvm/llvm/ffi.rs
src/librustc_codegen_llvm/llvm/ffi.rs
+4
-4
src/librustc_codegen_llvm/llvm/mod.rs
src/librustc_codegen_llvm/llvm/mod.rs
+1
-1
src/librustc_codegen_llvm/meth.rs
src/librustc_codegen_llvm/meth.rs
+5
-5
src/librustc_codegen_llvm/mir/block.rs
src/librustc_codegen_llvm/mir/block.rs
+7
-10
src/librustc_codegen_llvm/mir/constant.rs
src/librustc_codegen_llvm/mir/constant.rs
+4
-4
src/librustc_codegen_llvm/mir/mod.rs
src/librustc_codegen_llvm/mir/mod.rs
+1
-1
未找到文件。
src/librustc_codegen_llvm/abi.rs
浏览文件 @
3e77f2fc
...
...
@@ -244,7 +244,7 @@ fn store(
self
.layout.align
,
bx
.pointercast
(
llscratch
,
Type
::
i8p
(
cx
)),
scratch_align
,
CodegenCx
::
c_usize
(
cx
,
self
.layout.size
.bytes
()),
cx
.c_usize
(
self
.layout.size
.bytes
()),
MemFlags
::
empty
());
bx
.lifetime_end
(
llscratch
,
scratch_size
);
...
...
src/librustc_codegen_llvm/asm.rs
浏览文件 @
3e77f2fc
...
...
@@ -111,7 +111,7 @@ pub fn codegen_inline_asm(
let
kind
=
llvm
::
LLVMGetMDKindIDInContext
(
bx
.cx
()
.llcx
,
key
.as_ptr
()
as
*
const
c_char
,
key
.len
()
as
c_uint
);
let
val
:
&
'll
Value
=
CodegenCx
::
c_i32
(
bx
.cx
(),
ia
.ctxt
.outer
()
.as_u32
()
as
i32
);
let
val
:
&
'll
Value
=
bx
.cx
()
.c_i32
(
ia
.ctxt
.outer
()
.as_u32
()
as
i32
);
llvm
::
LLVMSetMetadata
(
r
,
kind
,
llvm
::
LLVMMDNodeInContext
(
bx
.cx
()
.llcx
,
&
val
,
1
));
...
...
src/librustc_codegen_llvm/base.rs
浏览文件 @
3e77f2fc
...
...
@@ -157,14 +157,14 @@ pub fn bin_op_to_fcmp_predicate(op: hir::BinOpKind) -> RealPredicate {
}
}
pub
fn
compare_simd_types
(
bx
:
&
Builder
<
'a
,
'll
,
'tcx
>
,
lhs
:
&
'll
Value
,
rhs
:
&
'll
Value
,
pub
fn
compare_simd_types
<
'a
,
'll
:
'a
,
'tcx
:
'll
,
Builder
:
BuilderMethods
<
'a
,
'll
,
'tcx
>>
(
bx
:
&
Builder
,
lhs
:
Builder
::
Value
,
rhs
:
Builder
::
Value
,
t
:
Ty
<
'tcx
>
,
ret_ty
:
&
'll
Type
,
ret_ty
:
Builder
::
Type
,
op
:
hir
::
BinOpKind
)
->
&
'll
Value
{
)
->
Builder
::
Value
{
let
signed
=
match
t
.sty
{
ty
::
Float
(
_
)
=>
{
let
cmp
=
bin_op_to_fcmp_predicate
(
op
);
...
...
@@ -198,7 +198,7 @@ pub fn unsized_info(
let
(
source
,
target
)
=
cx
.tcx
.struct_lockstep_tails
(
source
,
target
);
match
(
&
source
.sty
,
&
target
.sty
)
{
(
&
ty
::
Array
(
_
,
len
),
&
ty
::
Slice
(
_
))
=>
{
CodegenCx
::
c_usize
(
cx
,
len
.unwrap_usize
(
cx
.tcx
))
cx
.c_usize
(
len
.unwrap_usize
(
cx
.tcx
))
}
(
&
ty
::
Dynamic
(
..
),
&
ty
::
Dynamic
(
..
))
=>
{
// For now, upcasts are limited to changes in marker
...
...
@@ -460,7 +460,7 @@ pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll>(
return
;
}
call_memcpy
(
bx
,
dst
,
dst_align
,
src
,
src_align
,
CodegenCx
::
c_usize
(
bx
.cx
(),
size
),
flags
);
call_memcpy
(
bx
,
dst
,
dst_align
,
src
,
src_align
,
bx
.cx
()
.c_usize
(
size
),
flags
);
}
pub
fn
call_memset
(
...
...
@@ -474,7 +474,7 @@ pub fn call_memset(
let
ptr_width
=
&
bx
.cx
()
.sess
()
.target.target.target_pointer_width
;
let
intrinsic_key
=
format!
(
"llvm.memset.p0i8.i{}"
,
ptr_width
);
let
llintrinsicfn
=
bx
.cx
()
.get_intrinsic
(
&
intrinsic_key
);
let
volatile
=
CodegenCx
::
c_bool
(
bx
.cx
(),
volatile
);
let
volatile
=
bx
.cx
()
.c_bool
(
volatile
);
bx
.call
(
llintrinsicfn
,
&
[
ptr
,
fill_byte
,
size
,
align
,
volatile
],
None
)
}
...
...
src/librustc_codegen_llvm/builder.rs
浏览文件 @
3e77f2fc
...
...
@@ -577,7 +577,7 @@ fn store_with_flags(
// *always* point to a metadata value of the integer 1.
//
// [1]: http://llvm.org/docs/LangRef.html#store-instruction
let
one
=
CodegenCx
::
c_i32
(
self
.cx
,
1
);
let
one
=
self
.cx
.c_i32
(
1
);
let
node
=
llvm
::
LLVMMDNodeInContext
(
self
.cx.llcx
,
&
one
,
1
);
llvm
::
LLVMSetMetadata
(
store
,
llvm
::
MD_nontemporal
as
c_uint
,
node
);
}
...
...
@@ -861,7 +861,7 @@ fn vector_splat(&self, num_elts: usize, elt: &'ll Value) -> &'ll Value {
unsafe
{
let
elt_ty
=
self
.cx
.val_ty
(
elt
);
let
undef
=
llvm
::
LLVMGetUndef
(
type_
::
Type
::
vector
(
elt_ty
,
num_elts
as
u64
));
let
vec
=
self
.insert_element
(
undef
,
elt
,
CodegenCx
::
c_i32
(
self
.cx
,
0
));
let
vec
=
self
.insert_element
(
undef
,
elt
,
self
.cx
.c_i32
(
0
));
let
vec_i32_ty
=
type_
::
Type
::
vector
(
type_
::
Type
::
i32
(
self
.cx
),
num_elts
as
u64
);
self
.shuffle_vector
(
vec
,
undef
,
self
.cx
.c_null
(
vec_i32_ty
))
}
...
...
@@ -1227,7 +1227,7 @@ fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: &'ll Value, size: Size)
let
lifetime_intrinsic
=
self
.cx
.get_intrinsic
(
intrinsic
);
let
ptr
=
self
.pointercast
(
ptr
,
type_
::
Type
::
i8p
(
self
.cx
));
self
.call
(
lifetime_intrinsic
,
&
[
CodegenCx
::
c_u64
(
self
.cx
,
size
),
ptr
],
None
);
self
.call
(
lifetime_intrinsic
,
&
[
self
.cx
.c_u64
(
size
),
ptr
],
None
);
}
fn
call
(
&
self
,
llfn
:
&
'll
Value
,
args
:
&
[
&
'll
Value
],
...
...
src/librustc_codegen_llvm/common.rs
浏览文件 @
3e77f2fc
...
...
@@ -50,7 +50,7 @@ pub fn type_is_freeze<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bo
ty
.is_freeze
(
tcx
,
ty
::
ParamEnv
::
reveal_all
(),
DUMMY_SP
)
}
pub
struct
OperandBundleDef
<
'a
,
Value
:
'a
>
{
pub
struct
OperandBundleDef
<
'a
,
Value
:
'a
>
{
pub
name
:
&
'a
str
,
pub
val
:
Value
}
...
...
@@ -200,7 +200,7 @@ impl Backend for CodegenCx<'ll, 'tcx> {
type
Context
=
&
'll
llvm
::
Context
;
}
impl
<
'll
,
'tcx
:
'll
>
CommonMethods
for
CodegenCx
<
'll
,
'tcx
>
{
impl
<
'll
,
'tcx
:
'll
>
CommonMethods
for
CodegenCx
<
'll
,
'tcx
>
{
// LLVM constant constructors.
fn
c_null
(
&
self
,
t
:
&
'll
Type
)
->
&
'll
Value
{
...
...
@@ -424,7 +424,7 @@ pub fn c_struct_in_context(
}
}
impl
<
'll
,
'tcx
:
'll
>
CommonWriteMethods
for
CodegenCx
<
'll
,
'tcx
>
{
impl
<
'll
,
'tcx
:
'll
>
CommonWriteMethods
for
CodegenCx
<
'll
,
'tcx
>
{
fn
val_ty
(
&
self
,
v
:
&
'll
Value
)
->
&
'll
Type
{
val_ty
(
v
)
}
...
...
src/librustc_codegen_llvm/debuginfo/gdb.rs
浏览文件 @
3e77f2fc
...
...
@@ -30,7 +30,7 @@ pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &Builder) {
let
gdb_debug_scripts_section
=
get_or_insert_gdb_debug_scripts_section_global
(
bx
.cx
());
// Load just the first byte as that's all that's necessary to force
// LLVM to keep around the reference to the global.
let
indices
=
[
CodegenCx
::
c_i32
(
bx
.cx
(),
0
),
CodegenCx
::
c_i32
(
bx
.cx
(),
0
)];
let
indices
=
[
bx
.cx
()
.c_i32
(
0
),
bx
.cx
()
.c_i32
(
0
)];
let
element
=
bx
.inbounds_gep
(
gdb_debug_scripts_section
,
&
indices
);
let
volative_load_instruction
=
bx
.volatile_load
(
element
);
unsafe
{
...
...
@@ -64,7 +64,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>)
bug!
(
"symbol `{}` is already defined"
,
section_var_name
)
});
llvm
::
LLVMSetSection
(
section_var
,
section_name
.as_ptr
()
as
*
const
_
);
llvm
::
LLVMSetInitializer
(
section_var
,
CodegenCx
::
c_bytes
(
cx
,
section_contents
));
llvm
::
LLVMSetInitializer
(
section_var
,
cx
.c_bytes
(
section_contents
));
llvm
::
LLVMSetGlobalConstant
(
section_var
,
llvm
::
True
);
llvm
::
LLVMSetUnnamedAddr
(
section_var
,
llvm
::
True
);
llvm
::
LLVMRustSetLinkage
(
section_var
,
llvm
::
Linkage
::
LinkOnceODRLinkage
);
...
...
src/librustc_codegen_llvm/glue.rs
浏览文件 @
3e77f2fc
...
...
@@ -16,7 +16,6 @@
use
builder
::
Builder
;
use
common
::
*
;
use
context
::
CodegenCx
;
use
meth
;
use
rustc
::
ty
::
layout
::
LayoutOf
;
use
rustc
::
ty
::{
self
,
Ty
};
...
...
@@ -66,8 +65,8 @@ pub fn size_and_align_of_dst(
let
sized_align
=
layout
.align
.abi
();
debug!
(
"DST {} statically sized prefix size: {} align: {}"
,
t
,
sized_size
,
sized_align
);
let
sized_size
=
CodegenCx
::
c_usize
(
cx
,
sized_size
);
let
sized_align
=
CodegenCx
::
c_usize
(
cx
,
sized_align
);
let
sized_size
=
cx
.c_usize
(
sized_size
);
let
sized_align
=
cx
.c_usize
(
sized_align
);
// Recurse to get the size of the dynamically sized field (must be
// the last field).
...
...
@@ -98,7 +97,7 @@ pub fn size_and_align_of_dst(
(
Some
(
sized_align
),
Some
(
unsized_align
))
=>
{
// If both alignments are constant, (the sized_align should always be), then
// pick the correct alignment statically.
CodegenCx
::
c_usize
(
cx
,
std
::
cmp
::
max
(
sized_align
,
unsized_align
)
as
u64
)
cx
.c_usize
(
std
::
cmp
::
max
(
sized_align
,
unsized_align
)
as
u64
)
}
_
=>
bx
.select
(
bx
.icmp
(
IntPredicate
::
IntUGT
,
sized_align
,
unsized_align
),
sized_align
,
...
...
@@ -116,7 +115,7 @@ pub fn size_and_align_of_dst(
//
// `(size + (align-1)) & -align`
let
addend
=
bx
.sub
(
align
,
CodegenCx
::
c_usize
(
bx
.cx
(),
1
));
let
addend
=
bx
.sub
(
align
,
bx
.cx
()
.c_usize
(
1
));
let
size
=
bx
.and
(
bx
.add
(
size
,
addend
),
bx
.neg
(
align
));
(
size
,
align
)
...
...
src/librustc_codegen_llvm/interfaces/backend.rs
浏览文件 @
3e77f2fc
...
...
@@ -8,8 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use
std
::
fmt
::
Debug
;
pub
trait
Backend
{
type
Value
;
type
Value
:
Debug
+
PartialEq
;
type
BasicBlock
;
type
Type
;
type
Context
;
...
...
src/librustc_codegen_llvm/interfaces/builder.rs
浏览文件 @
3e77f2fc
...
...
@@ -22,7 +22,7 @@
pub
trait
BuilderMethods
<
'a
,
'll
:
'a
,
'tcx
:
'll
>
:
Backend
{
pub
trait
BuilderMethods
<
'a
,
'll
:
'a
,
'tcx
:
'll
>
:
Backend
{
fn
new_block
<
'b
>
(
cx
:
&
'a
CodegenCx
<
'll
,
'tcx
,
Self
::
Value
>
,
...
...
@@ -271,7 +271,7 @@ fn check_call<'b>(
typ
:
&
str
,
llfn
:
Self
::
Value
,
args
:
&
'b
[
Self
::
Value
]
)
->
Cow
<
'b
,
[
Self
::
Value
]
>
where
[
Self
::
Value
]
:
ToOwned
;
)
->
Cow
<
'b
,
[
Self
::
Value
]
>
where
[
Self
::
Value
]:
ToOwned
;
fn
lifetime_start
(
&
self
,
ptr
:
Self
::
Value
,
size
:
Size
);
fn
lifetime_end
(
&
self
,
ptr
:
Self
::
Value
,
size
:
Size
);
...
...
src/librustc_codegen_llvm/interfaces/common.rs
浏览文件 @
3e77f2fc
...
...
@@ -11,7 +11,7 @@
use
super
::
Backend
;
use
syntax
::
symbol
::
LocalInternedString
;
pub
trait
CommonMethods
:
Backend
+
CommonWriteMethods
{
pub
trait
CommonMethods
:
Backend
+
CommonWriteMethods
{
// Constant constructors
fn
c_null
(
&
self
,
t
:
Self
::
Type
)
->
Self
::
Value
;
fn
c_undef
(
&
self
,
t
:
Self
::
Type
)
->
Self
::
Value
;
...
...
@@ -47,12 +47,13 @@ fn c_struct(
fn
const_get_elt
(
&
self
,
v
:
Self
::
Value
,
idx
:
u64
)
->
Self
::
Value
;
fn
const_get_real
(
&
self
,
v
:
Self
::
Value
)
->
Option
<
(
f64
,
bool
)
>
;
fn
const_to_uint
(
&
self
,
v
:
Self
::
Value
)
->
u64
;
fn
const_to_opt_u128
(
&
self
,
v
:
Self
::
Value
,
sign_ext
:
bool
)
->
Option
<
u128
>
;
fn
is_const_integral
(
&
self
,
v
:
Self
::
Value
)
->
bool
;
fn
is_const_real
(
&
self
,
v
:
Self
::
Value
)
->
bool
;
fn
const_to_opt_u128
(
&
self
,
v
:
Self
::
Value
,
sign_ext
:
bool
)
->
Option
<
u128
>
;
}
pub
trait
CommonWriteMethods
:
Backend
{
pub
trait
CommonWriteMethods
:
Backend
{
fn
val_ty
(
&
self
,
v
:
Self
::
Value
)
->
Self
::
Type
;
fn
c_bytes_in_context
(
&
self
,
llcx
:
Self
::
Context
,
bytes
:
&
[
u8
])
->
Self
::
Value
;
fn
c_struct_in_context
(
...
...
src/librustc_codegen_llvm/llvm/ffi.rs
浏览文件 @
3e77f2fc
...
...
@@ -246,7 +246,7 @@ pub enum AtomicRmwBinOp {
}
impl
AtomicRmwBinOp
{
pub
fn
from_generic
(
op
:
common
::
AtomicRmwBinOp
)
->
Self
{
pub
fn
from_generic
(
op
:
common
::
AtomicRmwBinOp
)
->
Self
{
match
op
{
common
::
AtomicRmwBinOp
::
AtomicXchg
=>
AtomicRmwBinOp
::
AtomicXchg
,
common
::
AtomicRmwBinOp
::
AtomicAdd
=>
AtomicRmwBinOp
::
AtomicAdd
,
...
...
@@ -279,7 +279,7 @@ pub enum AtomicOrdering {
}
impl
AtomicOrdering
{
pub
fn
from_generic
(
ao
:
common
::
AtomicOrdering
)
->
Self
{
pub
fn
from_generic
(
ao
:
common
::
AtomicOrdering
)
->
Self
{
match
ao
{
common
::
AtomicOrdering
::
NotAtomic
=>
AtomicOrdering
::
NotAtomic
,
common
::
AtomicOrdering
::
Unordered
=>
AtomicOrdering
::
Unordered
,
...
...
@@ -306,7 +306,7 @@ pub enum SynchronizationScope {
}
impl
SynchronizationScope
{
pub
fn
from_generic
(
sc
:
common
::
SynchronizationScope
)
->
Self
{
pub
fn
from_generic
(
sc
:
common
::
SynchronizationScope
)
->
Self
{
match
sc
{
common
::
SynchronizationScope
::
Other
=>
SynchronizationScope
::
Other
,
common
::
SynchronizationScope
::
SingleThread
=>
SynchronizationScope
::
SingleThread
,
...
...
@@ -356,7 +356,7 @@ pub enum AsmDialect {
}
impl
AsmDialect
{
pub
fn
from_generic
(
asm
:
syntax
::
ast
::
AsmDialect
)
->
Self
{
pub
fn
from_generic
(
asm
:
syntax
::
ast
::
AsmDialect
)
->
Self
{
match
asm
{
syntax
::
ast
::
AsmDialect
::
Att
=>
AsmDialect
::
Att
,
syntax
::
ast
::
AsmDialect
::
Intel
=>
AsmDialect
::
Intel
...
...
src/librustc_codegen_llvm/llvm/mod.rs
浏览文件 @
3e77f2fc
...
...
@@ -273,7 +273,7 @@ pub fn new(name: &str, vals: &[&'a Value]) -> Self {
OperandBundleDef
{
raw
:
def
}
}
pub
fn
from_generic
(
bundle
:
&
common
::
OperandBundleDef
<
'a
,
&
'a
Value
>
)
->
Self
{
pub
fn
from_generic
(
bundle
:
&
common
::
OperandBundleDef
<
'a
,
&
'a
Value
>
)
->
Self
{
Self
::
new
(
bundle
.name
,
&
[
bundle
.val
])
}
}
...
...
src/librustc_codegen_llvm/meth.rs
浏览文件 @
3e77f2fc
...
...
@@ -44,7 +44,7 @@ pub fn get_fn(self, bx: &Builder<'a, 'll, 'tcx>,
let
llvtable
=
bx
.pointercast
(
llvtable
,
fn_ty
.ptr_to_llvm_type
(
bx
.cx
())
.ptr_to
());
let
ptr_align
=
bx
.tcx
()
.data_layout.pointer_align
;
let
ptr
=
bx
.load
(
bx
.inbounds_gep
(
llvtable
,
&
[
CodegenCx
::
c_usize
(
bx
.cx
(),
self
.0
)]),
bx
.inbounds_gep
(
llvtable
,
&
[
bx
.cx
()
.c_usize
(
self
.0
)]),
ptr_align
);
bx
.nonnull_metadata
(
ptr
);
...
...
@@ -64,7 +64,7 @@ pub fn get_usize(
let
llvtable
=
bx
.pointercast
(
llvtable
,
Type
::
isize
(
bx
.cx
())
.ptr_to
());
let
usize_align
=
bx
.tcx
()
.data_layout.pointer_align
;
let
ptr
=
bx
.load
(
bx
.inbounds_gep
(
llvtable
,
&
[
CodegenCx
::
c_usize
(
bx
.cx
(),
self
.0
)]),
bx
.inbounds_gep
(
llvtable
,
&
[
bx
.cx
()
.c_usize
(
self
.0
)]),
usize_align
);
// Vtable loads are invariant
...
...
@@ -112,11 +112,11 @@ pub fn get_vtable(
// /////////////////////////////////////////////////////////////////////////////////////////////
let
components
:
Vec
<
_
>
=
[
callee
::
get_fn
(
cx
,
monomorphize
::
resolve_drop_in_place
(
cx
.tcx
,
ty
)),
CodegenCx
::
c_usize
(
cx
,
size
.bytes
()),
CodegenCx
::
c_usize
(
cx
,
align
.abi
())
cx
.c_usize
(
size
.bytes
()),
cx
.c_usize
(
align
.abi
())
]
.iter
()
.cloned
()
.chain
(
methods
)
.collect
();
let
vtable_const
=
CodegenCx
::
c_struct
(
cx
,
&
components
,
false
);
let
vtable_const
=
cx
.c_struct
(
&
components
,
false
);
let
align
=
cx
.data_layout
()
.pointer_align
;
let
vtable
=
consts
::
addr_of
(
cx
,
vtable_const
,
align
,
Some
(
"vtable"
));
...
...
src/librustc_codegen_llvm/mir/block.rs
浏览文件 @
3e77f2fc
...
...
@@ -19,7 +19,6 @@
use
callee
;
use
builder
::{
Builder
,
MemFlags
};
use
common
::{
self
,
IntPredicate
};
use
context
::
CodegenCx
;
use
consts
;
use
meth
;
use
monomorphize
;
...
...
@@ -347,7 +346,7 @@ fn codegen_terminator(&mut self,
// Pass the condition through llvm.expect for branch hinting.
let
expect
=
bx
.cx
()
.get_intrinsic
(
&
"llvm.expect.i1"
);
let
cond
=
bx
.call
(
expect
,
&
[
cond
,
CodegenCx
::
c_bool
(
bx
.cx
(),
expected
)],
None
);
let
cond
=
bx
.call
(
expect
,
&
[
cond
,
bx
.cx
()
.c_bool
(
expected
)],
None
);
// Create the failure block and the conditional branch to it.
let
lltarget
=
llblock
(
self
,
target
);
...
...
@@ -365,9 +364,9 @@ fn codegen_terminator(&mut self,
// Get the location information.
let
loc
=
bx
.sess
()
.source_map
()
.lookup_char_pos
(
span
.lo
());
let
filename
=
Symbol
::
intern
(
&
loc
.file.name
.to_string
())
.as_str
();
let
filename
=
CodegenCx
::
c_str_slice
(
bx
.cx
(),
filename
);
let
line
=
CodegenCx
::
c_u32
(
bx
.cx
(),
loc
.line
as
u32
);
let
col
=
CodegenCx
::
c_u32
(
bx
.cx
(),
loc
.col
.to_usize
()
as
u32
+
1
);
let
filename
=
bx
.cx
()
.c_str_slice
(
filename
);
let
line
=
bx
.cx
()
.c_u32
(
loc
.line
as
u32
);
let
col
=
bx
.cx
()
.c_u32
(
loc
.col
.to_usize
()
as
u32
+
1
);
let
align
=
tcx
.data_layout.aggregate_align
.max
(
tcx
.data_layout.i32_align
)
.max
(
tcx
.data_layout.pointer_align
);
...
...
@@ -378,8 +377,7 @@ fn codegen_terminator(&mut self,
let
len
=
self
.codegen_operand
(
&
mut
bx
,
len
)
.immediate
();
let
index
=
self
.codegen_operand
(
&
mut
bx
,
index
)
.immediate
();
let
file_line_col
=
CodegenCx
::
c_struct
(
bx
.cx
(),
&
[
filename
,
line
,
col
],
false
);
let
file_line_col
=
bx
.cx
()
.c_struct
(
&
[
filename
,
line
,
col
],
false
);
let
file_line_col
=
consts
::
addr_of
(
bx
.cx
(),
file_line_col
,
align
,
...
...
@@ -390,9 +388,8 @@ fn codegen_terminator(&mut self,
_
=>
{
let
str
=
msg
.description
();
let
msg_str
=
Symbol
::
intern
(
str
)
.as_str
();
let
msg_str
=
CodegenCx
::
c_str_slice
(
bx
.cx
(),
msg_str
);
let
msg_file_line_col
=
CodegenCx
::
c_struct
(
bx
.cx
(),
let
msg_str
=
bx
.cx
()
.c_str_slice
(
msg_str
);
let
msg_file_line_col
=
bx
.cx
()
.c_struct
(
&
[
msg_str
,
filename
,
line
,
col
],
false
);
...
...
src/librustc_codegen_llvm/mir/constant.rs
浏览文件 @
3e77f2fc
...
...
@@ -96,7 +96,7 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll
assert_eq!
(
offset
as
usize
as
u64
,
offset
);
let
offset
=
offset
as
usize
;
if
offset
>
next_offset
{
llvals
.push
(
CodegenCx
::
c_bytes
(
cx
,
&
alloc
.bytes
[
next_offset
..
offset
]));
llvals
.push
(
cx
.c_bytes
(
&
alloc
.bytes
[
next_offset
..
offset
]));
}
let
ptr_offset
=
read_target_uint
(
dl
.endian
,
...
...
@@ -114,10 +114,10 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx<'ll, '_>, alloc: &Allocation) -> &'ll
next_offset
=
offset
+
pointer_size
;
}
if
alloc
.bytes
.len
()
>=
next_offset
{
llvals
.push
(
CodegenCx
::
c_bytes
(
cx
,
&
alloc
.bytes
[
next_offset
..
]));
llvals
.push
(
cx
.c_bytes
(
&
alloc
.bytes
[
next_offset
..
]));
}
CodegenCx
::
c_struct
(
cx
,
&
llvals
,
true
)
cx
.c_struct
(
&
llvals
,
true
)
}
pub
fn
codegen_static_initializer
(
...
...
@@ -207,7 +207,7 @@ pub fn simd_shuffle_indices(
bug!
(
"simd shuffle field {:?}"
,
field
)
}
})
.collect
();
let
llval
=
CodegenCx
::
c_struct
(
bx
.cx
(),
&
values
?
,
false
);
let
llval
=
bx
.cx
()
.c_struct
(
&
values
?
,
false
);
Ok
((
llval
,
c
.ty
))
})
.unwrap_or_else
(|
_
|
{
...
...
src/librustc_codegen_llvm/mir/mod.rs
浏览文件 @
3e77f2fc
...
...
@@ -421,7 +421,7 @@ fn create_funclets(
// it's null. The 64 here is actually a bitfield which
// represents that this is a catch-all block.
let
null
=
bx
.cx
()
.c_null
(
Type
::
i8p
(
bx
.cx
()));
let
sixty_four
=
CodegenCx
::
c_i32
(
bx
.cx
(),
64
);
let
sixty_four
=
bx
.cx
()
.c_i32
(
64
);
cleanup
=
cp_bx
.catch_pad
(
cs
,
&
[
null
,
sixty_four
,
null
]);
cp_bx
.br
(
llbb
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录