Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 12 additions & 2 deletions src/cmd/asm/internal/asm/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ func (p *Parser) operand(a *obj.Addr) {
}
if haveConstant {
p.back()
if p.have(scanner.Float) {
if p.have(scanner.Float) || p.haveIndent("Inf") || p.haveIndent("NaN") {
if prefix != '$' {
p.errorf("floating-point constant must be an immediate")
}
Expand Down Expand Up @@ -1284,7 +1284,7 @@ func (p *Parser) floatExpr() float64 {
return +p.floatExpr()
case '-':
return -p.floatExpr()
case scanner.Float:
case scanner.Float, scanner.Ident:
return p.atof(tok.String())
}
p.errorf("unexpected %s evaluating float expression", tok)
Expand Down Expand Up @@ -1467,6 +1467,16 @@ func (p *Parser) have(token lex.ScanToken) bool {
return false
}

// have reports whether the remaining tokens (including the current one) contain the specified token.
func (p *Parser) haveIndent(token string) bool {
for i := p.inputPos; i < len(p.input); i++ {
if p.input[i].String() == token {
return true
}
}
return false
}

// at reports whether the next tokens are as requested.
func (p *Parser) at(next ...lex.ScanToken) bool {
if len(p.input)-p.inputPos < len(next) {
Expand Down
89 changes: 89 additions & 0 deletions src/cmd/asm/internal/asm/testdata/riscv64.s
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,95 @@ start:
// 21.7: Double-Precision Floating-Point Classify Instruction
FCLASSD F0, X5 // d31200e2

// 24: "Zfa" Extension for Additional Floating-Point Instructions
// 24.1: Load-Immediate Instructions
FLIS $(NaN), F1 // d3801ff0
FLIS $(-1.0), F1 // d30010f0
FLIS $(-Inf), F1 // d38010f0
FLIS $(1.52587890625e-05), F1 // d30011f0
FLIS $(3.0517578125e-05), F1 // d38011f0
FLIS $(0.00390625), F1 // d30012f0
FLIS $(0.0078125), F1 // d38012f0
FLIS $(0.0625), F1 // d30013f0
FLIS $(0.125), F1 // d38013f0
FLIS $(0.25), F1 // d30014f0
FLIS $(0.3125), F1 // d38014f0
FLIS $(0.375), F1 // d30015f0
FLIS $(0.4375), F1 // d38015f0
FLIS $(0.5), F1 // d30016f0
FLIS $(0.625), F1 // d38016f0
FLIS $(0.75), F1 // d30017f0
FLIS $(0.875), F1 // d38017f0
FLIS $(1.0), F1 // d30018f0
FLIS $(1.25), F1 // d38018f0
FLIS $(1.5), F1 // d30019f0
FLIS $(1.75), F1 // d38019f0
FLIS $(2.0), F1 // d3001af0
FLIS $(2.5), F1 // d3801af0
FLIS $(3.0), F1 // d3001bf0
FLIS $(4.0), F1 // d3801bf0
FLIS $(8.0), F1 // d3001cf0
FLIS $(1.6000000000000001), F1 // d3801cf0
FLIS $(1.28), F1 // d3001df0
FLIS $(2.5600000000000001), F1 // d3801df0
FLIS $(3.27), F1 // d3001ef0
FLIS $(6.5499999999999998), F1 // d3801ef0
FLIS $(+Inf), F1 // d3001ff0
FLIS $(NaN), F1 // d3801ff0
FLID $(-1.0), F1 // d30010f2
FLID $(-Inf), F1 // d38010f2
FLID $(1.52587890625e-05), F1 // d30011f2
FLID $(3.0517578125e-05), F1 // d38011f2
FLID $(0.00390625), F1 // d30012f2
FLID $(0.0078125), F1 // d38012f2
FLID $(0.0625), F1 // d30013f2
FLID $(0.125), F1 // d38013f2
FLID $(0.25), F1 // d30014f2
FLID $(0.3125), F1 // d38014f2
FLID $(0.375), F1 // d30015f2
FLID $(0.4375), F1 // d38015f2
FLID $(0.5), F1 // d30016f2
FLID $(0.625), F1 // d38016f2
FLID $(0.75), F1 // d30017f2
FLID $(0.875), F1 // d38017f2
FLID $(1.0), F1 // d30018f2
FLID $(1.25), F1 // d38018f2
FLID $(1.5), F1 // d30019f2
FLID $(1.75), F1 // d38019f2
FLID $(2.0), F1 // d3001af2
FLID $(2.5), F1 // d3801af2
FLID $(3.0), F1 // d3001bf2
FLID $(4.0), F1 // d3801bf2
FLID $(8.0), F1 // d3001cf2
FLID $(1.6000000000000001), F1 // d3801cf2
FLID $(1.28), F1 // d3001df2
FLID $(2.5600000000000001), F1 // d3801df2
FLID $(3.27), F1 // d3001ef2
FLID $(6.5499999999999998), F1 // d3801ef2
FLID $(+Inf), F1 // d3001ff2
FLID $(NaN), F1 // d3801ff2

// 24.2: Minimum and Maximum Instructions
FMAXMD F21, F20, F19 // d3395a2b
FMAXMS F21, F20, F19 // d3395a29
FMINMD F12, F11, F10 // 53a5c52a
FMINMS F12, F11, F10 // 53a5c528

// 24.3: Round-to-Integer Instructions
FROUNDD F18, F9 // d3044942
FROUNDS F18, F9 // d3044940
FROUNDNXD F18, F9 // d3045942
FROUNDNXS F18, F9 // d3045940

// 24.4: Modular Convert-to-Integer Instruction
FCVTMODWD F1, X11 // d39580c2

// 24.6: Comparison Instructions
FLEQD F2, F1, X11 // d3c520a2
FLEQS F2, F1, X11 // d3c520a0
FLTQD F18, F9, X11 // d3d524a3
FLTQS F18, F9, X11 // d3d524a1

//
// "C" Extension for Compressed Instructions, Version 2.0
//
Expand Down
15 changes: 15 additions & 0 deletions src/cmd/internal/obj/riscv/anames.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/cmd/internal/obj/riscv/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,32 @@ const (
// 22.5: Quad-Precision Floating-Point Classify Instruction
AFCLASSQ

// 24: "Zfa" Extension for Additional Floating-Point Instructions
// 24.1: Load-Immediate Instructions
AFLIS
AFLID

// 24.2: Minimum and Maximum Instructions
AFMAXMS
AFMINMS
AFMAXMD
AFMINMD

// 24.3: Round-to-Integer Instructions
AFROUNDS
AFROUNDNXS
AFROUNDD
AFROUNDNXD

// 24.4: Modular Convert-to-Integer Instruction
AFCVTMODWD

// 24.6: Comparison Instructions
AFLEQS
AFLTQS
AFLEQD
AFLTQD

//
// "C" Extension for Compressed Instructions
//
Expand Down
34 changes: 31 additions & 3 deletions src/cmd/internal/obj/riscv/inst.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading