llvm.org GIT mirror llvm / 8e8b0ba
[x86] translating "fp" (floating point) instructions from {fadd,fdiv,fmul,fsub,fsubr,fdivr} to {faddp,fdivp,fmulp,fsubp,fsubrp,fdivrp} LLVM Missing the following instructions: fadd\fdiv\fmul\fsub\fsubr\fdivr. GAS and MS supporting this instruction and lowering them in to a faddp\fdivp\fmulp\fsubp\fsubrp\fdivrp instructions. Differential Revision: http://reviews.llvm.org/D14217 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252908 91177308-0d34-0410-b5e6-96231b3b80d8 Michael Zuckerman 4 years ago
4 changed file(s) with 44 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
22172217 (isPrefix && getLexer().is(AsmToken::Slash)))
22182218 Parser.Lex();
22192219
2220 // This is for gas compatibility and cannot be done in td.
2221 // Adding "p" for some floating point with no argument.
2222 // For example: fsub --> fsubp
2223 bool IsFp =
2224 Name == "fsub" || Name == "fdiv" || Name == "fsubr" || Name == "fdivr";
2225 if (IsFp && Operands.size() == 1) {
2226 const char *Repl = StringSwitch(Name)
2227 .Case("fsub", "fsubp")
2228 .Case("fdiv", "fdivp")
2229 .Case("fsubr", "fsubrp")
2230 .Case("fdivr", "fdivrp");
2231 static_cast(*Operands[0]).setTokenValue(Repl);
2232 }
2233
22202234 // This is a terrible hack to handle "out[bwl]? %al, (%dx)" ->
22212235 // "outb %al, %dx". Out doesn't take a memory form, but this is a widely
22222236 // documented form in various unofficial manuals, so a lot of code uses it.
27922792 // Various unary fpstack operations default to operating on on ST1.
27932793 // For example, "fxch" -> "fxch %st(1)"
27942794 def : InstAlias<"faddp", (ADD_FPrST0 ST1), 0>;
2795 def: InstAlias<"fadd", (ADD_FPrST0 ST1), 0>;
27952796 def : InstAlias<"fsub{|r}p", (SUBR_FPrST0 ST1), 0>;
27962797 def : InstAlias<"fsub{r|}p", (SUB_FPrST0 ST1), 0>;
2798 def : InstAlias<"fmul", (MUL_FPrST0 ST1), 0>;
27972799 def : InstAlias<"fmulp", (MUL_FPrST0 ST1), 0>;
27982800 def : InstAlias<"fdiv{|r}p", (DIVR_FPrST0 ST1), 0>;
27992801 def : InstAlias<"fdiv{r|}p", (DIV_FPrST0 ST1), 0>;
1414 .att_syntax prefix
1515 movl $255, -4(%rsp)
1616 // CHECK: movl $255, -4(%rsp)
17
18 _test3:
19 fadd
20 // CHECK: faddp %st(1)
21 fmul
22 // CHECK: fmulp %st(1)
23 fsub
24 // CHECK: fsubp %st(1)
25 fsubr
26 // CHECK: fsubrp %st(1)
27 fdiv
28 // CHECK: fdivp %st(1)
29 fdivr
30 // CHECK: fdivrp %st(1)
532532 fdivp ST(1)
533533 fdivrp ST(1)
534534
535
536 // CHECK: faddp %st(1)
537 // CHECK: fmulp %st(1)
538 // CHECK: fsubrp %st(1)
539 // CHECK: fsubp %st(1)
540 // CHECK: fdivrp %st(1)
541 // CHECK: fdivp %st(1)
542 fadd
543 fmul
544 fsub
545 fsubr
546 fdiv
547 fdivr
548
535549 // CHECK: faddp %st(1)
536550 // CHECK: fmulp %st(1)
537551 // CHECK: fsubrp %st(1)