Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Rake.application.options.thread_pool_size = $jobs
puts "Running with #{Rake.application.options.thread_pool_size} job(s)"

require "etc"
require "pathname"

$root = Pathname.new(__dir__).realpath
$lib = $root / "lib"
Expand Down
12 changes: 7 additions & 5 deletions backends/cpp_hart_gen/lib/decode_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,22 @@ def construct_decode_tree(tree, xlen, cur_range, test: false)

tree.insts.each do |inst|
inst_format = inst.encoding(xlen).format
if inst_format.reverse[cur_range].match?(/^[01]+$/)
range_bits = inst_format.reverse[cur_range]
if range_bits && range_bits.match?(/^[01]+$/)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this just converts a crash into an infinite loop. That's what I'm seeing in testing, anyway. Are you seeing something different?

Copy link
Contributor Author

@Sukuna0007Abhi Sukuna0007Abhi Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops sorry sir @ThinkOpenly I think I missed to add the another needy few lines here, sorry it's because I got very sad after lfx result😞 , sure sir will fix that

# puts "#{inst.name} has opcode bit(s) in #{cur_range} (#{inst_format.reverse[cur_range].reverse})"
# whole range is opcode bits
if inst_format.gsub('0', '1') == tree.mask(cur_range).to_s(2).gsub('0', '-').rjust(inst.encoding(xlen).size, '-')
done_insts[inst_format.reverse[cur_range]] = inst
done_insts[range_bits] = inst
else
in_progress_groups[inst_format.reverse[cur_range]] ||= []
in_progress_groups[inst_format.reverse[cur_range]] << inst
in_progress_groups[range_bits] ||= []
in_progress_groups[range_bits] << inst
end
else
# puts "#{inst.name} has variable bit(s) in #{cur_range} (#{inst_format.reverse[cur_range].reverse} #{inst_format.reverse})"
# puts "#{inst.name} has variable bit(s) in #{cur_range} (#{range_bits || 'nil'} #{inst_format.reverse})"
variable_insts << inst
end
end

if test
# puts "test result for #{cur_range}: #{variable_insts.empty?} (#{tree.insts.map(&:name)})"
return variable_insts.empty?
Expand Down
24 changes: 24 additions & 0 deletions spec/std/isa/inst/Zicfilp/sspopchk.x1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# yaml-language-server: $schema=../../../../schemas/inst_schema.json

$schema: inst_schema.json#
kind: instruction
name: sspopchk.x1
long_name: Shadow Stack Pop and Check X1
description: |
Pop a value from the shadow stack and check it against register x1.
definedBy: Zicfilp
assembly: x1
encoding:
match: "11001101110000001100000001110011"
variables: []
access:
s: always
u: always
vs: always
vu: always
data_independent_timing: false
operation(): |
# Pop value from shadow stack and check against register x1
24 changes: 24 additions & 0 deletions spec/std/isa/inst/Zicfilp/sspopchk.x5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# yaml-language-server: $schema=../../../../schemas/inst_schema.json

$schema: inst_schema.json#
kind: instruction
name: sspopchk.x5
long_name: Shadow Stack Pop and Check X5
description: |
Pop a value from the shadow stack and check it against register x5.
definedBy: Zicfilp
assembly: x5
encoding:
match: "11001101110000101100000001110011"
variables: []
access:
s: always
u: always
vs: always
vu: always
data_independent_timing: false
operation(): |
# Pop value from shadow stack and check against register x5
28 changes: 28 additions & 0 deletions spec/std/isa/inst/Zicfilp/sspopchk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# yaml-language-server: $schema=../../../../schemas/inst_schema.json

$schema: inst_schema.json#
kind: instruction
name: sspopchk
long_name: Shadow Stack Pop and Check
description: |
Pop a value from the shadow stack and check it.
definedBy: Zicfilp
assembly: xs1
encoding:
match: "110011011100-----100000001110011"
variables:
- name: xs1
location: 19-15
# prettier-ignore
not: [ 0, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 ]
access:
s: always
u: always
vs: always
vu: always
data_independent_timing: false
operation(): |
# Pop value from shadow stack and check against register xs1
24 changes: 24 additions & 0 deletions spec/std/isa/inst/Zicfilp/sspush.x1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# yaml-language-server: $schema=../../../../schemas/inst_schema.json

$schema: inst_schema.json#
kind: instruction
name: sspush.x1
long_name: Shadow Stack Push X1
description: |
Push a value from register x1 onto the shadow stack.
definedBy: Zicfilp
assembly: x1
encoding:
match: "11001110000100000100000001110011"
variables: []
access:
s: always
u: always
vs: always
vu: always
data_independent_timing: false
operation(): |
# Push value from register x1 onto shadow stack
24 changes: 24 additions & 0 deletions spec/std/isa/inst/Zicfilp/sspush.x5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# yaml-language-server: $schema=../../../../schemas/inst_schema.json

$schema: inst_schema.json#
kind: instruction
name: sspush.x5
long_name: Shadow Stack Push X5
description: |
Push a value from register x5 onto the shadow stack.
definedBy: Zicfilp
assembly: x5
encoding:
match: "11001110010100000100000001110011"
variables: []
access:
s: always
u: always
vs: always
vu: always
data_independent_timing: false
operation(): |
# Push value from register x5 onto shadow stack
28 changes: 28 additions & 0 deletions spec/std/isa/inst/Zicfilp/sspush.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# yaml-language-server: $schema=../../../../schemas/inst_schema.json

$schema: inst_schema.json#
kind: instruction
name: sspush
long_name: Shadow Stack Push
description: |
Push a value onto the shadow stack.
definedBy: Zicfilp
assembly: xs2
encoding:
match: "1100111-----00000100000001110011"
variables:
- name: xs2
location: 24-20
# prettier-ignore
not: [ 0, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 ]
access:
s: always
u: always
vs: always
vu: always
data_independent_timing: false
operation(): |
# Push value from register xs2 onto shadow stack
Loading