Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
50a2d47b
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
50a2d47b
编写于
10月 11, 2018
作者:
T
Tim Neumann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support for the program data address space option
of LLVM's Target Datalayout.
https://llvm.org/docs/LangRef.html#data-layout
上级
653da4fd
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
28 addition
and
5 deletion
+28
-5
src/librustc_codegen_llvm/abi.rs
src/librustc_codegen_llvm/abi.rs
+9
-1
src/librustc_codegen_llvm/meth.rs
src/librustc_codegen_llvm/meth.rs
+1
-1
src/librustc_codegen_llvm/type_.rs
src/librustc_codegen_llvm/type_.rs
+2
-0
src/librustc_codegen_llvm/type_of.rs
src/librustc_codegen_llvm/type_of.rs
+1
-1
src/librustc_target/abi/mod.rs
src/librustc_target/abi/mod.rs
+15
-2
未找到文件。
src/librustc_codegen_llvm/abi.rs
浏览文件 @
50a2d47b
...
...
@@ -19,7 +19,7 @@
use
type_of
::{
LayoutLlvmExt
,
PointerKind
};
use
value
::
Value
;
use
rustc_target
::
abi
::{
LayoutOf
,
Size
,
TyLayout
,
Abi
as
LayoutAbi
};
use
rustc_target
::
abi
::{
HasDataLayout
,
LayoutOf
,
Size
,
TyLayout
,
Abi
as
LayoutAbi
};
use
rustc
::
ty
::{
self
,
Ty
};
use
rustc
::
ty
::
layout
;
...
...
@@ -276,6 +276,7 @@ fn adjust_for_abi(&mut self,
cx
:
&
CodegenCx
<
'll
,
'tcx
>
,
abi
:
Abi
);
fn
llvm_type
(
&
self
,
cx
:
&
CodegenCx
<
'll
,
'tcx
>
)
->
&
'll
Type
;
fn
ptr_to_llvm_type
(
&
self
,
cx
:
&
CodegenCx
<
'll
,
'tcx
>
)
->
&
'll
Type
;
fn
llvm_cconv
(
&
self
)
->
llvm
::
CallConv
;
fn
apply_attrs_llfn
(
&
self
,
llfn
:
&
'll
Value
);
fn
apply_attrs_callsite
(
&
self
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
>
,
callsite
:
&
'll
Value
);
...
...
@@ -657,6 +658,13 @@ fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
}
}
fn
ptr_to_llvm_type
(
&
self
,
cx
:
&
CodegenCx
<
'll
,
'tcx
>
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMPointerType
(
self
.llvm_type
(
cx
),
cx
.data_layout
()
.instruction_address_space
as
c_uint
)
}
}
fn
llvm_cconv
(
&
self
)
->
llvm
::
CallConv
{
match
self
.conv
{
Conv
::
C
=>
llvm
::
CCallConv
,
...
...
src/librustc_codegen_llvm/meth.rs
浏览文件 @
50a2d47b
...
...
@@ -39,7 +39,7 @@ pub fn get_fn(self, bx: &Builder<'a, 'll, 'tcx>,
// Load the data pointer from the object.
debug!
(
"get_fn({:?}, {:?})"
,
llvtable
,
self
);
let
llvtable
=
bx
.pointercast
(
llvtable
,
fn_ty
.
llvm_type
(
bx
.cx
)
.ptr_to
(
)
.ptr_to
());
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
,
&
[
C_usize
(
bx
.cx
,
self
.0
)]),
ptr_align
);
bx
.nonnull_metadata
(
ptr
);
...
...
src/librustc_codegen_llvm/type_.rs
浏览文件 @
50a2d47b
...
...
@@ -234,6 +234,8 @@ pub fn set_struct_body(&'ll self, els: &[&'ll Type], packed: bool) {
}
pub
fn
ptr_to
(
&
self
)
->
&
Type
{
assert_ne!
(
self
.kind
(),
TypeKind
::
Function
,
"don't call ptr_to on function types, use ptr_to_llvm_type on FnType instead"
);
unsafe
{
llvm
::
LLVMPointerType
(
self
,
0
)
}
...
...
src/librustc_codegen_llvm/type_of.rs
浏览文件 @
50a2d47b
...
...
@@ -265,7 +265,7 @@ fn llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> &'a Type {
ty
::
ParamEnv
::
reveal_all
(),
&
sig
,
);
FnType
::
new
(
cx
,
sig
,
&
[])
.
llvm_type
(
cx
)
.ptr_to
(
)
FnType
::
new
(
cx
,
sig
,
&
[])
.
ptr_to_llvm_type
(
cx
)
}
_
=>
self
.scalar_llvm_type_at
(
cx
,
scalar
,
Size
::
ZERO
)
};
...
...
src/librustc_target/abi/mod.rs
浏览文件 @
50a2d47b
...
...
@@ -35,7 +35,8 @@ pub struct TargetDataLayout {
pub
aggregate_align
:
Align
,
/// Alignments for vector types.
pub
vector_align
:
Vec
<
(
Size
,
Align
)
>
pub
vector_align
:
Vec
<
(
Size
,
Align
)
>
,
pub
instruction_address_space
:
u32
,
}
impl
Default
for
TargetDataLayout
{
...
...
@@ -57,13 +58,22 @@ fn default() -> TargetDataLayout {
vector_align
:
vec!
[
(
Size
::
from_bits
(
64
),
Align
::
from_bits
(
64
,
64
)
.unwrap
()),
(
Size
::
from_bits
(
128
),
Align
::
from_bits
(
128
,
128
)
.unwrap
())
]
],
instruction_address_space
:
0
,
}
}
}
impl
TargetDataLayout
{
pub
fn
parse
(
target
:
&
Target
)
->
Result
<
TargetDataLayout
,
String
>
{
// Parse an address space index from a string.
let
parse_address_space
=
|
s
:
&
str
,
cause
:
&
str
|
{
s
.parse
::
<
u32
>
()
.map_err
(|
err
|
{
format!
(
"invalid address space `{}` for `{}` in
\"
data-layout
\"
: {}"
,
s
,
cause
,
err
)
})
};
// Parse a bit count from a string.
let
parse_bits
=
|
s
:
&
str
,
kind
:
&
str
,
cause
:
&
str
|
{
s
.parse
::
<
u64
>
()
.map_err
(|
err
|
{
...
...
@@ -96,6 +106,9 @@ pub fn parse(target: &Target) -> Result<TargetDataLayout, String> {
match
spec
.split
(
':'
)
.collect
::
<
Vec
<
_
>>
()[
..
]
{
[
"e"
]
=>
dl
.endian
=
Endian
::
Little
,
[
"E"
]
=>
dl
.endian
=
Endian
::
Big
,
[
p
]
if
p
.starts_with
(
"P"
)
=>
{
dl
.instruction_address_space
=
parse_address_space
(
&
p
[
1
..
],
"P"
)
?
}
[
"a"
,
ref
a
..
]
=>
dl
.aggregate_align
=
align
(
a
,
"a"
)
?
,
[
"f32"
,
ref
a
..
]
=>
dl
.f32_align
=
align
(
a
,
"f32"
)
?
,
[
"f64"
,
ref
a
..
]
=>
dl
.f64_align
=
align
(
a
,
"f64"
)
?
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录