Commit 4a55a602 by Karl Schimpf

Add vstr{s,d} to the integrated ARM assembler.

parent e1d71380
...@@ -757,8 +757,8 @@ void Assembler::vldrs(SRegister sd, Address ad, Condition cond) { ...@@ -757,8 +757,8 @@ void Assembler::vldrs(SRegister sd, Address ad, Condition cond) {
B11 | B9 | ad.vencoding(); B11 | B9 | ad.vencoding();
Emit(encoding); Emit(encoding);
} }
#endif
// Moved to Arm32::AssemblerARM32::vstrs()
void Assembler::vstrs(SRegister sd, Address ad, Condition cond) { void Assembler::vstrs(SRegister sd, Address ad, Condition cond) {
ASSERT(TargetCPUFeatures::vfp_supported()); ASSERT(TargetCPUFeatures::vfp_supported());
ASSERT(static_cast<Register>(ad.encoding_ & (0xf << kRnShift)) != PC); ASSERT(static_cast<Register>(ad.encoding_ & (0xf << kRnShift)) != PC);
...@@ -772,8 +772,6 @@ void Assembler::vstrs(SRegister sd, Address ad, Condition cond) { ...@@ -772,8 +772,6 @@ void Assembler::vstrs(SRegister sd, Address ad, Condition cond) {
Emit(encoding); Emit(encoding);
} }
#if 0
// Moved to ARM32::AssemblerARM32::vldrd()
void Assembler::vldrd(DRegister dd, Address ad, Condition cond) { void Assembler::vldrd(DRegister dd, Address ad, Condition cond) {
ASSERT(TargetCPUFeatures::vfp_supported()); ASSERT(TargetCPUFeatures::vfp_supported());
ASSERT(dd != kNoDRegister); ASSERT(dd != kNoDRegister);
......
...@@ -635,13 +635,15 @@ class Assembler : public ValueObject { ...@@ -635,13 +635,15 @@ class Assembler : public ValueObject {
#if 0 #if 0
// Moved to ARM32::AssemblerARM32::vldrs() // Moved to ARM32::AssemblerARM32::vldrs()
void vldrs(SRegister sd, Address ad, Condition cond = AL); void vldrs(SRegister sd, Address ad, Condition cond = AL);
#endif // Moved to Arm32::AssemblerARM32::vstrs()
void vstrs(SRegister sd, Address ad, Condition cond = AL); void vstrs(SRegister sd, Address ad, Condition cond = AL);
#if 0 #endif
// Moved to ARM32::AssemblerARM32::vldrd() // Moved to ARM32::AssemblerARM32::vldrd()
void vldrd(DRegister dd, Address ad, Condition cond = AL); void vldrd(DRegister dd, Address ad, Condition cond = AL);
#endif #if 0
// Moved to Arm32::AssemblerARM32::vstrd()
void vstrd(DRegister dd, Address ad, Condition cond = AL); void vstrd(DRegister dd, Address ad, Condition cond = AL);
#endif
void vldms(BlockAddressMode am, Register base, void vldms(BlockAddressMode am, Register base,
SRegister first, SRegister last, Condition cond = AL); SRegister first, SRegister last, Condition cond = AL);
......
...@@ -2262,6 +2262,47 @@ void AssemblerARM32::vmuld(const Operand *OpDd, const Operand *OpDn, ...@@ -2262,6 +2262,47 @@ void AssemblerARM32::vmuld(const Operand *OpDd, const Operand *OpDn,
emitVFPddd(Cond, VmuldOpcode, Dd, Dn, Dm); emitVFPddd(Cond, VmuldOpcode, Dd, Dn, Dm);
} }
void AssemblerARM32::vstrd(const Operand *OpDd, const Operand *OpAddress,
CondARM32::Cond Cond, const TargetInfo &TInfo) {
// VSTR - ARM section A8.8.413, encoding A1:
// vstr<c> <Dd>, [<Rn>{, #+/-<imm>}]
//
// cccc1101UD00nnnndddd1011iiiiiiii where cccc=Cond, nnnn=Rn, Ddddd=Rd,
// iiiiiiii=abs(Opcode), and U=1 if Opcode>=0,
constexpr const char *Vstrd = "vstrd";
IValueT Dd = encodeDRegister(OpDd, "Dd", Vstrd);
assert(CondARM32::isDefined(Cond));
IValueT Address;
if (encodeAddress(OpAddress, Address, TInfo) != EncodedAsImmRegOffset)
assert(false);
AssemblerBuffer::EnsureCapacity ensured(&Buffer);
IValueT Encoding = B27 | B26 | B24 | B11 | B9 | B8 |
(encodeCondition(Cond) << kConditionShift) |
(getYInRegYXXXX(Dd) << 22) |
(getXXXXInRegYXXXX(Dd) << 12) | Address;
emitInst(Encoding);
}
void AssemblerARM32::vstrs(const Operand *OpSd, const Operand *OpAddress,
CondARM32::Cond Cond, const TargetInfo &TInfo) {
// VSTR - ARM section A8.8.413, encoding A2:
// vstr<c> <Sd>, [<Rn>{, #+/-<imm>]]
//
// cccc1101UD01nnnndddd1010iiiiiiii where cccc=Cond, nnnn=Rn, ddddD=Sd,
// iiiiiiii=abs(Opcode), and U=1 if Opcode >= 0;
constexpr const char *Vstrs = "vstrs";
IValueT Sd = encodeSRegister(OpSd, "Sd", Vstrs);
assert(CondARM32::isDefined(Cond));
IValueT Address;
if (encodeAddress(OpAddress, Address, TInfo) != EncodedAsImmRegOffset)
assert(false);
AssemblerBuffer::EnsureCapacity ensured(&Buffer);
IValueT Encoding =
B27 | B26 | B24 | B11 | B9 | (encodeCondition(Cond) << kConditionShift) |
(getYInRegXXXXY(Sd) << 22) | (getXXXXInRegXXXXY(Sd) << 12) | Address;
emitInst(Encoding);
}
void AssemblerARM32::vsubs(const Operand *OpSd, const Operand *OpSn, void AssemblerARM32::vsubs(const Operand *OpSd, const Operand *OpSn,
const Operand *OpSm, CondARM32::Cond Cond) { const Operand *OpSm, CondARM32::Cond Cond) {
// VSUB (floating-point) - ARM section A8.8.415, encoding A2: // VSUB (floating-point) - ARM section A8.8.415, encoding A2:
......
...@@ -368,6 +368,24 @@ public: ...@@ -368,6 +368,24 @@ public:
void vpush(const Variable *OpBaseReg, SizeT NumConsecRegs, void vpush(const Variable *OpBaseReg, SizeT NumConsecRegs,
CondARM32::Cond Cond); CondARM32::Cond Cond);
void vstrd(const Operand *OpDd, const Operand *OpAddress,
CondARM32::Cond Cond, const TargetInfo &TInfo);
void vstrd(const Operand *OpDd, const Operand *OpAddress,
CondARM32::Cond Cond, const TargetLowering *Lowering) {
const TargetInfo TInfo(Lowering);
vstrd(OpDd, OpAddress, Cond, TInfo);
}
void vstrs(const Operand *OpSd, const Operand *OpAddress,
CondARM32::Cond Cond, const TargetInfo &TInfo);
void vstrs(const Operand *OpSd, const Operand *OpAddress,
CondARM32::Cond Cond, const TargetLowering *Lowering) {
const TargetInfo TInfo(Lowering);
vstrs(OpSd, OpAddress, Cond, TInfo);
}
void vsubd(const Operand *OpDd, const Operand *OpDn, const Operand *OpDm, void vsubd(const Operand *OpDd, const Operand *OpDn, const Operand *OpDm,
CondARM32::Cond Cond); CondARM32::Cond Cond);
......
...@@ -1668,7 +1668,12 @@ void InstARM32Str::emitIAS(const Cfg *Func) const { ...@@ -1668,7 +1668,12 @@ void InstARM32Str::emitIAS(const Cfg *Func) const {
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
Type Ty = getSrc(0)->getType(); Type Ty = getSrc(0)->getType();
auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>(); auto *Asm = Func->getAssembler<ARM32::AssemblerARM32>();
if (isVectorType(Ty) || isScalarFloatingType(Ty)) if (isScalarFloatingType(Ty)) {
if (Ty == IceType_f32)
Asm->vstrs(getSrc(0), getSrc(1), getPredicate(), Func->getTarget());
else
Asm->vstrd(getSrc(0), getSrc(1), getPredicate(), Func->getTarget());
} else if (isVectorType(Ty))
// TODO(kschimpf) Handle case. // TODO(kschimpf) Handle case.
Asm->setNeedsTextFixup(); Asm->setNeedsTextFixup();
else else
......
; Show that we know how to translate (floating point) vstr.
; REQUIRES: allow_dump
; Compile using standalone assembler.
; RUN: %p2i --filetype=asm -i %s --target=arm32 --args -O2 \
; RUN: -reg-use r5,r6,s20,d20 \
; RUN: | FileCheck %s --check-prefix=ASM
; Show bytes in assembled standalone code.
; RUN: %p2i --filetype=asm -i %s --target=arm32 --assemble --disassemble \
; RUN: --args -O2 \
; RUN: -reg-use r5,r6,s20,d20 \
; RUN: | FileCheck %s --check-prefix=DIS
; Compile using integrated assembler.
; RUN: %p2i --filetype=iasm -i %s --target=arm32 --args -O2 \
; RUN: -reg-use r5,r6,s20,d20 \
; RUN: | FileCheck %s --check-prefix=IASM
; Show bytes in assembled integrated code.
; RUN: %p2i --filetype=iasm -i %s --target=arm32 --assemble --disassemble \
; RUN: --args -O2 \
; RUN: -reg-use r5,r6,s20,d20 \
; RUN: | FileCheck %s --check-prefix=DIS
define internal void @testFloat() {
; ASM-LABEL: testFloat:
; DIS-LABEL: 00000000 <testFloat>:
; IASM-LABEL: testFloat:
entry:
; ASM: .LtestFloat$entry:
%vaddr = inttoptr i32 0 to float*
store float 0.0, float* %vaddr, align 1
; ASM: vstr s20, [r5]
; DIS: 14: ed96aa00
; IASM-NOT: vstr
ret void
}
define internal void @testDouble() {
; ASM-LABEL: testDouble:
; DIS-LABEL: 00000030 <testDouble>:
; IASM-LABEL: testDouble:
entry:
; ASM: .LtestDouble$entry:
%vaddr = inttoptr i32 0 to double*
store double 0.0, double* %vaddr, align 1
; ASM: vstr d20, [r5]
; DIS: 3c: edc54b00
; IASM-NOT: vstr
ret void
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment