Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5802f603
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,发现更多精彩内容 >>
提交
5802f603
编写于
8月 25, 2021
作者:
J
Jacob Lifshay
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add support for clobbering xer, cr, and cr[0-7] for asm! on OpenPower/PowerPC
Fixes #88315
上级
0afc2086
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
135 addition
and
10 deletion
+135
-10
compiler/rustc_codegen_llvm/src/asm.rs
compiler/rustc_codegen_llvm/src/asm.rs
+8
-0
compiler/rustc_span/src/symbol.rs
compiler/rustc_span/src/symbol.rs
+2
-0
compiler/rustc_target/src/asm/mod.rs
compiler/rustc_target/src/asm/mod.rs
+1
-1
compiler/rustc_target/src/asm/powerpc.rs
compiler/rustc_target/src/asm/powerpc.rs
+60
-9
src/doc/unstable-book/src/library-features/asm.md
src/doc/unstable-book/src/library-features/asm.md
+4
-0
src/test/assembly/asm/powerpc-types.rs
src/test/assembly/asm/powerpc-types.rs
+12
-0
src/test/codegen/asm-powerpc-clobbers.rs
src/test/codegen/asm-powerpc-clobbers.rs
+48
-0
未找到文件。
compiler/rustc_codegen_llvm/src/asm.rs
浏览文件 @
5802f603
...
...
@@ -615,6 +615,10 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'tcx>>)
InlineAsmRegClass
::
PowerPC
(
PowerPCInlineAsmRegClass
::
reg
)
=>
"r"
,
InlineAsmRegClass
::
PowerPC
(
PowerPCInlineAsmRegClass
::
reg_nonzero
)
=>
"b"
,
InlineAsmRegClass
::
PowerPC
(
PowerPCInlineAsmRegClass
::
freg
)
=>
"f"
,
InlineAsmRegClass
::
PowerPC
(
PowerPCInlineAsmRegClass
::
cr
)
|
InlineAsmRegClass
::
PowerPC
(
PowerPCInlineAsmRegClass
::
xer
)
=>
{
unreachable!
(
"clobber-only"
)
}
InlineAsmRegClass
::
RiscV
(
RiscVInlineAsmRegClass
::
reg
)
=>
"r"
,
InlineAsmRegClass
::
RiscV
(
RiscVInlineAsmRegClass
::
freg
)
=>
"f"
,
InlineAsmRegClass
::
RiscV
(
RiscVInlineAsmRegClass
::
vreg
)
=>
{
...
...
@@ -751,6 +755,10 @@ fn dummy_output_type(cx: &CodegenCx<'ll, 'tcx>, reg: InlineAsmRegClass) -> &'ll
InlineAsmRegClass
::
PowerPC
(
PowerPCInlineAsmRegClass
::
reg
)
=>
cx
.type_i32
(),
InlineAsmRegClass
::
PowerPC
(
PowerPCInlineAsmRegClass
::
reg_nonzero
)
=>
cx
.type_i32
(),
InlineAsmRegClass
::
PowerPC
(
PowerPCInlineAsmRegClass
::
freg
)
=>
cx
.type_f64
(),
InlineAsmRegClass
::
PowerPC
(
PowerPCInlineAsmRegClass
::
cr
)
|
InlineAsmRegClass
::
PowerPC
(
PowerPCInlineAsmRegClass
::
xer
)
=>
{
unreachable!
(
"clobber-only"
)
}
InlineAsmRegClass
::
RiscV
(
RiscVInlineAsmRegClass
::
reg
)
=>
cx
.type_i32
(),
InlineAsmRegClass
::
RiscV
(
RiscVInlineAsmRegClass
::
freg
)
=>
cx
.type_f32
(),
InlineAsmRegClass
::
RiscV
(
RiscVInlineAsmRegClass
::
vreg
)
=>
{
...
...
compiler/rustc_span/src/symbol.rs
浏览文件 @
5802f603
...
...
@@ -478,6 +478,7 @@
core_panic_macro
,
cosf32
,
cosf64
,
cr
,
crate_id
,
crate_in_paths
,
crate_local
,
...
...
@@ -1415,6 +1416,7 @@
wreg
,
write_bytes
,
x87_reg
,
xer
,
xmm_reg
,
ymm_reg
,
zmm_reg
,
...
...
compiler/rustc_target/src/asm/mod.rs
浏览文件 @
5802f603
...
...
@@ -344,7 +344,7 @@ pub fn overlapping_regs(self, mut cb: impl FnMut(InlineAsmReg)) {
Self
::
Arm
(
r
)
=>
r
.overlapping_regs
(|
r
|
cb
(
Self
::
Arm
(
r
))),
Self
::
AArch64
(
_
)
=>
cb
(
self
),
Self
::
RiscV
(
_
)
=>
cb
(
self
),
Self
::
PowerPC
(
_
)
=>
cb
(
self
),
Self
::
PowerPC
(
r
)
=>
r
.overlapping_regs
(|
r
|
cb
(
Self
::
PowerPC
(
r
))
),
Self
::
Hexagon
(
r
)
=>
r
.overlapping_regs
(|
r
|
cb
(
Self
::
Hexagon
(
r
))),
Self
::
Mips
(
_
)
=>
cb
(
self
),
Self
::
Bpf
(
r
)
=>
r
.overlapping_regs
(|
r
|
cb
(
Self
::
Bpf
(
r
))),
...
...
compiler/rustc_target/src/asm/powerpc.rs
浏览文件 @
5802f603
...
...
@@ -7,6 +7,8 @@
reg
,
reg_nonzero
,
freg
,
cr
,
xer
,
}
}
...
...
@@ -44,6 +46,7 @@ pub fn supported_types(
}
}
Self
::
freg
=>
types!
{
_
:
F32
,
F64
;
},
Self
::
cr
|
Self
::
xer
=>
&
[],
}
}
}
...
...
@@ -108,6 +111,16 @@ pub fn supported_types(
f29
:
freg
=
[
"f29"
,
"fr29"
],
f30
:
freg
=
[
"f30"
,
"fr30"
],
f31
:
freg
=
[
"f31"
,
"fr31"
],
cr
:
cr
=
[
"cr"
],
cr0
:
cr
=
[
"cr0"
],
cr1
:
cr
=
[
"cr1"
],
cr2
:
cr
=
[
"cr2"
],
cr3
:
cr
=
[
"cr3"
],
cr4
:
cr
=
[
"cr4"
],
cr5
:
cr
=
[
"cr5"
],
cr6
:
cr
=
[
"cr6"
],
cr7
:
cr
=
[
"cr7"
],
xer
:
xer
=
[
"xer"
],
#
error
=
[
"r1"
,
"1"
,
"sp"
]
=>
"the stack pointer cannot be used as an operand for inline asm"
,
#
error
=
[
"r2"
,
"2"
]
=>
...
...
@@ -136,17 +149,55 @@ pub fn emit(
_
arch
:
InlineAsmArch
,
_
modifier
:
Option
<
char
>
,
)
->
fmt
::
Result
{
macro_rules!
do_emit
{
(
$
(
$
((
$reg:ident
,
$value:literal
)),
*
;)
*
)
=>
{
out
.write_str
(
match
self
{
$
(
$
(
Self
::
$reg
=>
$value
,)
*
)
*
})
};
}
// Strip off the leading prefix.
if
self
as
u32
<=
Self
::
r28
as
u32
{
let
index
=
self
as
u32
-
Self
::
r28
as
u32
;
write!
(
out
,
"{}"
,
index
)
}
else
if
self
as
u32
>=
Self
::
f0
as
u32
&&
self
as
u32
<=
Self
::
f31
as
u32
{
let
index
=
self
as
u32
-
Self
::
f31
as
u32
;
write!
(
out
,
"{}"
,
index
)
}
else
{
unreachable!
()
do_emit!
{
(
r0
,
"0"
),
(
r3
,
"3"
),
(
r4
,
"4"
),
(
r5
,
"5"
),
(
r6
,
"6"
),
(
r7
,
"7"
);
(
r8
,
"8"
),
(
r9
,
"9"
),
(
r10
,
"10"
),
(
r11
,
"11"
),
(
r12
,
"12"
),
(
r14
,
"14"
),
(
r15
,
"15"
);
(
r16
,
"16"
),
(
r17
,
"17"
),
(
r18
,
"18"
),
(
r19
,
"19"
),
(
r20
,
"20"
),
(
r21
,
"21"
),
(
r22
,
"22"
),
(
r23
,
"23"
);
(
r24
,
"24"
),
(
r25
,
"25"
),
(
r26
,
"26"
),
(
r27
,
"27"
),
(
r28
,
"28"
);
(
f0
,
"0"
),
(
f1
,
"1"
),
(
f2
,
"2"
),
(
f3
,
"3"
),
(
f4
,
"4"
),
(
f5
,
"5"
),
(
f6
,
"6"
),
(
f7
,
"7"
);
(
f8
,
"8"
),
(
f9
,
"9"
),
(
f10
,
"10"
),
(
f11
,
"11"
),
(
f12
,
"12"
),
(
f13
,
"13"
),
(
f14
,
"14"
),
(
f15
,
"15"
);
(
f16
,
"16"
),
(
f17
,
"17"
),
(
f18
,
"18"
),
(
f19
,
"19"
),
(
f20
,
"20"
),
(
f21
,
"21"
),
(
f22
,
"22"
),
(
f23
,
"23"
);
(
f24
,
"24"
),
(
f25
,
"25"
),
(
f26
,
"26"
),
(
f27
,
"27"
),
(
f28
,
"28"
),
(
f29
,
"29"
),
(
f30
,
"30"
),
(
f31
,
"31"
);
(
cr
,
"cr"
);
(
cr0
,
"0"
),
(
cr1
,
"1"
),
(
cr2
,
"2"
),
(
cr3
,
"3"
),
(
cr4
,
"4"
),
(
cr5
,
"5"
),
(
cr6
,
"6"
),
(
cr7
,
"7"
);
(
xer
,
"xer"
);
}
}
pub
fn
overlapping_regs
(
self
,
mut
_
cb
:
impl
FnMut
(
PowerPCInlineAsmReg
))
{}
pub
fn
overlapping_regs
(
self
,
mut
cb
:
impl
FnMut
(
PowerPCInlineAsmReg
))
{
macro_rules!
reg_conflicts
{
(
$
(
$full:ident
:
$
(
$field:ident
)
*
),
*
;
)
=>
{
match
self
{
$
(
Self
::
$full
=>
{
cb
(
Self
::
$full
);
$
(
cb
(
Self
::
$field
);)
*
}
$
(
Self
::
$field
)|
*
=>
{
cb
(
Self
::
$full
);
cb
(
self
);
}
)
*
r
=>
cb
(
r
),
}
};
}
reg_conflicts!
{
cr
:
cr0
cr1
cr2
cr3
cr4
cr5
cr6
cr7
;
}
}
}
src/doc/unstable-book/src/library-features/asm.md
浏览文件 @
5802f603
...
...
@@ -584,6 +584,8 @@ Here is the list of currently supported register classes:
| PowerPC |
`reg`
|
`r[0-31]`
|
`r`
|
| PowerPC |
`reg_nonzero`
| |
`r[1-31]`
|
`b`
|
| PowerPC |
`freg`
|
`f[0-31]`
|
`f`
|
| PowerPC |
`cr`
|
`cr[0-7]`
,
`cr`
| Only clobbers |
| PowerPC |
`xer`
|
`xer`
| Only clobbers |
| wasm32 |
`local`
| None
\*
|
`r`
|
| BPF |
`reg`
|
`r[0-10]`
|
`r`
|
| BPF |
`wreg`
|
`w[0-10]`
|
`w`
|
...
...
@@ -637,6 +639,8 @@ Each register class has constraints on which value types they can be used with.
| PowerPC |
`reg`
| None |
`i8`
,
`i16`
,
`i32`
|
| PowerPC |
`reg_nonzero`
| None |
`i8`
,
`i16`
,
`i32`
|
| PowerPC |
`freg`
| None |
`f32`
,
`f64`
|
| PowerPC |
`cr`
| N/A | Only clobbers |
| PowerPC |
`xer`
| N/A | Only clobbers |
| wasm32 |
`local`
| None |
`i8`
`i16`
`i32`
`i64`
`f32`
`f64`
|
| BPF |
`reg`
| None |
`i8`
`i16`
`i32`
`i64`
|
| BPF |
`wreg`
|
`alu32`
|
`i8`
`i16`
`i32`
|
...
...
src/test/assembly/asm/powerpc-types.rs
浏览文件 @
5802f603
...
...
@@ -194,3 +194,15 @@ pub unsafe fn $func(x: $ty) -> $ty {
// CHECK: fmr 0, 0
// CHECK: #NO_APP
check_reg!
(
reg_f64_f0
,
f64
,
"0"
,
"f0"
,
"fmr"
);
// CHECK-LABEL: reg_f32_f18:
// CHECK: #APP
// CHECK: fmr 18, 18
// CHECK: #NO_APP
check_reg!
(
reg_f32_f18
,
f32
,
"18"
,
"f18"
,
"fmr"
);
// CHECK-LABEL: reg_f64_f18:
// CHECK: #APP
// CHECK: fmr 18, 18
// CHECK: #NO_APP
check_reg!
(
reg_f64_f18
,
f64
,
"18"
,
"f18"
,
"fmr"
);
src/test/codegen/asm-powerpc-clobbers.rs
0 → 100644
浏览文件 @
5802f603
// min-llvm-version: 10.0.1
// revisions: powerpc powerpc64 powerpc64le
//[powerpc] compile-flags: --target powerpc-unknown-linux-gnu
//[powerpc] needs-llvm-components: powerpc
//[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
//[powerpc64] needs-llvm-components: powerpc
//[powerpc64le] compile-flags: --target powerpc64le-unknown-linux-gnu
//[powerpc64le] needs-llvm-components: powerpc
#![crate_type
=
"rlib"
]
#![feature(no_core,
rustc_attrs,
lang_items)]
#![no_core]
#[lang
=
"sized"
]
trait
Sized
{}
#[rustc_builtin_macro]
macro_rules!
asm
{
()
=>
{};
}
// CHECK-LABEL: @cr_clobber
// CHECK: call void asm sideeffect "", "~{cr}"()
#[no_mangle]
pub
unsafe
fn
cr_clobber
()
{
asm!
(
""
,
out
(
"cr"
)
_
,
options
(
nostack
,
nomem
));
}
// CHECK-LABEL: @cr0_clobber
// CHECK: call void asm sideeffect "", "~{cr0}"()
#[no_mangle]
pub
unsafe
fn
cr0_clobber
()
{
asm!
(
""
,
out
(
"cr0"
)
_
,
options
(
nostack
,
nomem
));
}
// CHECK-LABEL: @cr5_clobber
// CHECK: call void asm sideeffect "", "~{cr5}"()
#[no_mangle]
pub
unsafe
fn
cr5_clobber
()
{
asm!
(
""
,
out
(
"cr5"
)
_
,
options
(
nostack
,
nomem
));
}
// CHECK-LABEL: @xer_clobber
// CHECK: call void asm sideeffect "", "~{xer}"()
#[no_mangle]
pub
unsafe
fn
xer_clobber
()
{
asm!
(
""
,
out
(
"xer"
)
_
,
options
(
nostack
,
nomem
));
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录