Skip to content

Commit e25601e

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[vm, compiler] Use bit-manipulation extensions when targeting Android or Fuchsia RISC-V.
Use Zbb instructions when available for ClampedUint8List stores. Use Zba instructions when available for IntConverter zero extensions. Fix LslImmediate(kUnsignedFourBytes) when Zba is enabled. TEST=locally switch to RV64GCB Change-Id: If9fc0ac3fd2c5248785322f949e2003024e5152a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385640 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 36da75d commit e25601e

File tree

9 files changed

+69
-340
lines changed

9 files changed

+69
-340
lines changed

runtime/vm/compiler/assembler/assembler_riscv.cc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,9 +2406,7 @@ void MicroAssembler::EmitJType(intptr_t imm, Register rd, Opcode opcode) {
24062406

24072407
Assembler::Assembler(ObjectPoolBuilder* object_pool_builder,
24082408
intptr_t far_branch_level)
2409-
: MicroAssembler(object_pool_builder,
2410-
far_branch_level,
2411-
FLAG_use_compressed_instructions ? RV_GC : RV_G),
2409+
: MicroAssembler(object_pool_builder, far_branch_level, RV_baseline),
24122410
constant_pool_allowed_(false) {
24132411
generate_invoke_write_barrier_wrapper_ = [&](Register reg) {
24142412
// Note this does not destroy RA.
@@ -2572,7 +2570,7 @@ void Assembler::ExtendValue(Register rd, Register rn, OperandSize sz) {
25722570
return mv(rd, rn);
25732571
case kUnsignedFourBytes:
25742572
if (Supports(RV_Zba)) {
2575-
return adduw(rd, rn, ZR);
2573+
return zextw(rd, rn);
25762574
}
25772575
slli(rd, rn, XLEN - 32);
25782576
return srli(rd, rn, XLEN - 32);
@@ -3311,13 +3309,12 @@ void Assembler::LslImmediate(Register rd,
33113309
return slliw(rd, rn, shift);
33123310
}
33133311
if (sz == kUnsignedFourBytes) {
3314-
if (Supports(RV_Zba)) {
3315-
return slliuw(rd, rn, shift);
3316-
} else {
3317-
// Clear upper bits in addition to the shift.
3318-
slli(rd, rn, shift + (XLEN / 2));
3319-
return srli(rd, rn, XLEN / 2);
3320-
}
3312+
// Not slliuw even when available. That zero extends the input, not the
3313+
// output.
3314+
3315+
// Clear upper bits in addition to the shift.
3316+
slli(rd, rn, shift + (XLEN / 2));
3317+
return srli(rd, rn, XLEN / 2);
33213318
}
33223319
#endif
33233320
slli(rd, rn, shift);

runtime/vm/compiler/assembler/assembler_riscv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class MicroAssembler : public AssemblerBase {
6969
#if defined(TESTING)
7070
void SetExtensions(ExtensionSet extensions) { extensions_ = extensions; }
7171
#endif
72+
ExtensionSet extensions() const { return extensions_; }
7273
bool Supports(Extension extension) const {
7374
return extensions_.Includes(extension);
7475
}
@@ -562,6 +563,8 @@ class MicroAssembler : public AssemblerBase {
562563
void sh3adduw(Register rd, Register rs1, Register rs2);
563564
void slliuw(Register rd, Register rs1, intx_t imm);
564565

566+
void zextw(Register rd, Register rs) { adduw(rd, rs, ZR); }
567+
565568
// ==== Zbb: Basic bit-manipulation ====
566569
void andn(Register rd, Register rs1, Register rs2);
567570
void orn(Register rd, Register rs1, Register rs2);

0 commit comments

Comments
 (0)