<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">> For the record, gcc does use $at for code generation, take a look at mips_print_operand for the @ symbol and then look at all of the cases it's being used.<br>
<br>
That's correct. However, LLVM currently doesn't use $at for codegen and quite a bit of effort has been put in to making that the case. I'd like to retain this advantage over GCC if I can.<br>
<br>
> This is a pretty weird hack, I think you could instead just look for uses of $at or macro instructions<br>
<br>
I think inspecting the assembly text to automatically discover clobbers would be a nice feature but it would mean that GCC wouldn't correctly handle inline assembly that works fine on LLVM. I don't think we need to do that now. The goal at the moment is to
become compatible with GCC's inline assembly so that LLVM-compiled Linux works for Mips.<br>
<br>
> (unless that other patch recently just set nomacro for inline assembly).<br>
<br>
The other patch effectively prepends '.set macro', '.set reorder', and '.set at' to the inline assembly to match the values that GCC is using for inline assembly (and codegen in general). After the inline assembly it reverts back to the mode LLVM normally uses.
This is because there are quite a few inline assembly blocks in the linux kernel that expect .set macro/reorder/at.<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF734928"><font color="#000000" face="Tahoma" size="2"><b>From:</b> Eric Christopher [echristo@gmail.com]<br>
<b>Sent:</b> 18 December 2014 20:29<br>
<b>To:</b> reviews+D6638+public+9dbc664d9cbf7b31@reviews.llvm.org; Toma Tabacu; Daniel Sanders<br>
<b>Cc:</b> cfe-commits@cs.uiuc.edu<br>
<b>Subject:</b> Re: [PATCH] [mips] Always clobber $1 for MIPS inline asm.<br>
</font><br>
</div>
<div></div>
<div>For the record, gcc does use $at for code generation, take a look at mips_print_operand for the @ symbol and then look at all of the cases it's being used.<br>
<div><br>
</div>
<div>This is a pretty weird hack, I think you could instead just look for uses of $at or macro instructions (unless that other patch recently just set nomacro for inline assembly).</div>
<div><br>
</div>
<div>-eric</div>
<br>
<div class="gmail_quote">On Thu Dec 18 2014 at 8:06:36 AM Toma Tabacu <<a href="mailto:toma.tabacu@imgtec.com" target="_blank">toma.tabacu@imgtec.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
Removed FIXME, as suggested in the review.<br>
<br>
<br>
<a href="http://reviews.llvm.org/D6638" target="_blank">http://reviews.llvm.org/D6638</a><br>
<br>
Files:<br>
lib/Basic/Targets.cpp<br>
test/CodeGen/mips-constraint-<u></u>regs.c<br>
test/CodeGen/mips-constraints-<u></u>mem.c<br>
test/CodeGen/mips-inline-asm-<u></u>modifiers.c<br>
test/CodeGen/mult-alt-generic.<u></u>c<br>
<br>
Index: lib/Basic/Targets.cpp<br>
==============================<u></u>==============================<u></u>=======<br>
--- lib/Basic/Targets.cpp<br>
+++ lib/Basic/Targets.cpp<br>
@@ -5749,8 +5749,7 @@<br>
}<br>
<br>
const char *getClobbers() const override {<br>
- // FIXME: Implement!<br>
- return "";<br>
+ return "~{$1}";<br>
}<br>
<br>
bool handleTargetFeatures(std::<u></u>vector<std::string> &Features,<br>
Index: test/CodeGen/mips-constraint-<u></u>regs.c<br>
==============================<u></u>==============================<u></u>=======<br>
--- test/CodeGen/mips-constraint-<u></u>regs.c<br>
+++ test/CodeGen/mips-constraint-<u></u>regs.c<br>
@@ -9,7 +9,7 @@<br>
// 'c': 16 bit address register for Mips16, GPR for all others<br>
// I am using 'c' to constrain both the target and one of the source<br>
// registers. We are looking for syntactical correctness.<br>
- // CHECK: %{{[0-9]+}} = call i32 asm sideeffect "addi $0,$1,$2 \0A\09\09", "=c,c,I"(i32 %{{[0-9]+}}, i32 %{{[0-9]+}}) [[NUW:#[0-9]+]], !srcloc !{{[0-9]+}}<br>
+ // CHECK: %{{[0-9]+}} = call i32 asm sideeffect "addi $0,$1,$2 \0A\09\09", "=c,c,I,~{$1}"(i32 %{{[0-9]+}}, i32 %{{[0-9]+}}) [[NUW:#[0-9]+]], !srcloc !{{[0-9]+}}<br>
int __s, __v = 17;<br>
int __t;<br>
__asm__ __volatile__(<br>
@@ -20,7 +20,7 @@<br>
// 'l': lo register<br>
// We are making it clear that destination register is lo with the<br>
// use of the 'l' constraint ("=l").<br>
- // CHECK: %{{[0-9]+}} = call i32 asm sideeffect "mtlo $1 \0A\09\09", "=l,r,~{lo}"(i32 %{{[0-9]+}}) [[NUW]], !srcloc !{{[0-9]+}}<br>
+ // CHECK: %{{[0-9]+}} = call i32 asm sideeffect "mtlo $1 \0A\09\09", "=l,r,~{lo},~{$1}"(i32 %{{[0-9]+}}) [[NUW]], !srcloc !{{[0-9]+}}<br>
int i_temp = 44;<br>
int i_result;<br>
__asm__ __volatile__(<br>
@@ -32,7 +32,7 @@<br>
// 'x': Combined lo/hi registers<br>
// We are specifying that destination registers are the hi/lo pair with the<br>
// use of the 'x' constraint ("=x").<br>
- // CHECK: %{{[0-9]+}} = call i64 asm sideeffect "mthi $1 \0A\09\09mtlo $2 \0A\09\09", "=x,r,r"(i32 %{{[0-9]+}}, i32 %{{[0-9]+}}) [[NUW]], !srcloc !{{[0-9]+}}<br>
+ // CHECK: %{{[0-9]+}} = call i64 asm sideeffect "mthi $1 \0A\09\09mtlo $2 \0A\09\09", "=x,r,r,~{$1}"(i32 %{{[0-9]+}}, i32 %{{[0-9]+}}) [[NUW]], !srcloc !{{[0-9]+}}<br>
int i_hi = 3;<br>
int i_lo = 2;<br>
long long ll_result = 0;<br>
Index: test/CodeGen/mips-constraints-<u></u>mem.c<br>
==============================<u></u>==============================<u></u>=======<br>
--- test/CodeGen/mips-constraints-<u></u>mem.c<br>
+++ test/CodeGen/mips-constraints-<u></u>mem.c<br>
@@ -9,7 +9,7 @@<br>
// 'R': An address that can be used in a non-macro load or stor'<br>
// This test will result in the higher and lower nibbles being<br>
// switched due to the lwl/lwr instruction pairs.<br>
- // CHECK: %{{[0-9]+}} = call i32 asm sideeffect "lwl $0, 1 + $1\0A\09lwr $0, 2 + $1\0A\09", "=r,*R"(i32* %{{[0-9,a-f]+}}) #1,<br>
+ // CHECK: %{{[0-9]+}} = call i32 asm sideeffect "lwl $0, 1 + $1\0A\09lwr $0, 2 + $1\0A\09", "=r,*R,~{$1}"(i32* %{{[0-9,a-f]+}}) #1,<br>
<br>
int c = 0xffbbccdd;<br>
<br>
Index: test/CodeGen/mips-inline-asm-<u></u>modifiers.c<br>
==============================<u></u>==============================<u></u>=======<br>
--- test/CodeGen/mips-inline-asm-<u></u>modifiers.c<br>
+++ test/CodeGen/mips-inline-asm-<u></u>modifiers.c<br>
@@ -7,9 +7,9 @@<br>
<br>
typedef int v4i32 __attribute__((vector_size(16)<u></u>));<br>
<br>
- // CHECK: %{{[0-9]+}} = call i32 asm ".set noreorder;\0Alw $0,$1;\0A.set reorder;\0A", "=r,*m"(i32* getelementptr inbounds ([8 x i32]* @b, i32 {{[0-9]+}}, i32 {{[0-9]+}})) #2,<br>
- // CHECK: %{{[0-9]+}} = call i32 asm "lw $0,${1:D};\0A", "=r,*m"(i32* getelementptr inbounds ([8 x i32]* @b, i32 {{[0-9]+}}, i32 {{[0-9]+}})) #2,<br>
- // CHECK: %{{[0-9]+}} = call <4 x i32> asm "ldi.w ${0:w},1", "=f"<br>
+ // CHECK: %{{[0-9]+}} = call i32 asm ".set noreorder;\0Alw $0,$1;\0A.set reorder;\0A", "=r,*m,~{$1}"(i32* getelementptr inbounds ([8 x i32]* @b, i32 {{[0-9]+}}, i32 {{[0-9]+}})) #2,<br>
+ // CHECK: %{{[0-9]+}} = call i32 asm "lw $0,${1:D};\0A", "=r,*m,~{$1}"(i32* getelementptr inbounds ([8 x i32]* @b, i32 {{[0-9]+}}, i32 {{[0-9]+}})) #2,<br>
+ // CHECK: %{{[0-9]+}} = call <4 x i32> asm "ldi.w ${0:w},1", "=f,~{$1}"<br>
int b[8] = {0,1,2,3,4,5,6,7};<br>
int main()<br>
{<br>
Index: test/CodeGen/mult-alt-generic.<u></u>c<br>
==============================<u></u>==============================<u></u>=======<br>
--- test/CodeGen/mult-alt-generic.<u></u>c<br>
+++ test/CodeGen/mult-alt-generic.<u></u>c<br>
@@ -17,7 +17,7 @@<br>
// CHECK: @single_m<br>
void single_m()<br>
{<br>
- // CHECK: call void asm "foo $1,$0", "=*m,*m[[CLOBBERS:[a-zA-Z0-9@%<u></u>{},~_ ]*\"]](i32* {{[a-zA-Z0-9@%]+}}, i32* {{[a-zA-Z0-9@%]+}})<br>
+ // CHECK: call void asm "foo $1,$0", "=*m,*m[[CLOBBERS:[a-zA-Z0-9@%<u></u>{},~_$ ]*\"]](i32* {{[a-zA-Z0-9@%]+}}, i32* {{[a-zA-Z0-9@%]+}})<br>
asm("foo %1,%0" : "=m" (mout0) : "m" (min1));<br>
}<br>
<br>
EMAIL PREFERENCES<br>
<a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">
http://reviews.llvm.org/<u></u>settings/panel/<u></u>emailpreferences/</a><br>
______________________________<u></u>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-commits</a><br>
</blockquote>
</div>
</div>
</div>
</div>
</body>
</html>