From 600f7533857010399d07c8dbcd4fcc5e88b24f36 Mon Sep 17 00:00:00 2001 From: Lu Yahan Date: Wed, 6 Jul 2022 09:12:39 +0800 Subject: [PATCH] [riscv64] Port [fastcall] Support EnforceRange annotation Port commit 8559a04f4ce6cbaa95831ffde18f9e89be0d53fe Change-Id: Ibeafd18e3bed0907536b93d1fd4c5db98bef41ba Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3746292 Commit-Queue: ji qiu Auto-Submit: Yahan Lu Reviewed-by: ji qiu Cr-Commit-Position: refs/heads/main@{#81544} --- .../riscv64/instruction-selector-riscv64.cc | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/compiler/backend/riscv64/instruction-selector-riscv64.cc b/src/compiler/backend/riscv64/instruction-selector-riscv64.cc index 742b42249e..b0fa3cca3c 100644 --- a/src/compiler/backend/riscv64/instruction-selector-riscv64.cc +++ b/src/compiler/backend/riscv64/instruction-selector-riscv64.cc @@ -1268,6 +1268,36 @@ void InstructionSelector::VisitChangeFloat64ToInt32(Node* node) { VisitRR(this, kRiscvTruncWD, node); } +void InstructionSelector::VisitTryTruncateFloat64ToInt32(Node* node) { + RiscvOperandGenerator g(this); + InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; + InstructionOperand outputs[2]; + size_t output_count = 0; + outputs[output_count++] = g.DefineAsRegister(node); + + Node* success_output = NodeProperties::FindProjection(node, 1); + if (success_output) { + outputs[output_count++] = g.DefineAsRegister(success_output); + } + + this->Emit(kRiscvTruncWD, output_count, outputs, 1, inputs); +} + +void InstructionSelector::VisitTryTruncateFloat64ToUint32(Node* node) { + RiscvOperandGenerator g(this); + InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; + InstructionOperand outputs[2]; + size_t output_count = 0; + outputs[output_count++] = g.DefineAsRegister(node); + + Node* success_output = NodeProperties::FindProjection(node, 1); + if (success_output) { + outputs[output_count++] = g.DefineAsRegister(success_output); + } + + Emit(kRiscvTruncUwD, output_count, outputs, 1, inputs); +} + void InstructionSelector::VisitChangeFloat64ToInt64(Node* node) { VisitRR(this, kRiscvTruncLD, node); }