Skip to content

Commit 7a2a5ce

Browse files
committed
ir/constant: fix go doc comments (for Go 1.19 syntax)
1 parent 23b8806 commit 7a2a5ce

File tree

4 files changed

+79
-64
lines changed

4 files changed

+79
-64
lines changed

ir/constant/const_float.go

+15-10
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,21 @@ func NewFloat(typ *types.FloatType, x float64) *Float {
4949
//
5050
// The floating-point string may be expressed in one of the following forms.
5151
//
52-
// - fraction floating-point literal
53-
// [+-]? [0-9]+ [.] [0-9]*
54-
// - scientific notation floating-point literal
55-
// [+-]? [0-9]+ [.] [0-9]* [eE] [+-]? [0-9]+
56-
// - hexadecimal floating-point literal
57-
// 0x[0-9A-Fa-f]{16} // HexFP
58-
// 0xK[0-9A-Fa-f]{20} // HexFP80
59-
// 0xL[0-9A-Fa-f]{32} // HexFP128
60-
// 0xM[0-9A-Fa-f]{32} // HexPPC128
61-
// 0xH[0-9A-Fa-f]{4} // HexHalf
52+
// Fraction floating-point literal.
53+
//
54+
// [+-]? [0-9]+ [.] [0-9]*
55+
//
56+
// Scientific notation floating-point literal.
57+
//
58+
// [+-]? [0-9]+ [.] [0-9]* [eE] [+-]? [0-9]+
59+
//
60+
// Hexadecimal floating-point literal.
61+
//
62+
// 0x[0-9A-Fa-f]{16} // HexFP
63+
// 0xK[0-9A-Fa-f]{20} // HexFP80
64+
// 0xL[0-9A-Fa-f]{32} // HexFP128
65+
// 0xM[0-9A-Fa-f]{32} // HexPPC128
66+
// 0xH[0-9A-Fa-f]{4} // HexHalf
6267
func NewFloatFromString(typ *types.FloatType, s string) (*Float, error) {
6368
// Hexadecimal floating-point literal.
6469
if strings.HasPrefix(s, "0x") {

ir/constant/const_int.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,17 @@ func NewBool(x bool) *Int {
3838
//
3939
// The integer string may be expressed in one of the following forms.
4040
//
41-
// - boolean literal
42-
// true | false
43-
// - integer literal
44-
// [-]?[0-9]+
45-
// - hexadecimal integer literal
46-
// [us]0x[0-9A-Fa-f]+
41+
// Boolean literal.
42+
//
43+
// true | false
44+
//
45+
// Integer literal.
46+
//
47+
// [-]?[0-9]+
48+
//
49+
// Hexadecimal integer literal.
50+
//
51+
// [us]0x[0-9A-Fa-f]+
4752
func NewIntFromString(typ *types.IntType, s string) (*Int, error) {
4853
// Boolean literal.
4954
switch s {

ir/constant/constant.go

+23-18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package constant
33

44
import (
5+
"github.com/llir/llvm/ir"
56
"github.com/llir/llvm/ir/types"
67
"github.com/llir/llvm/ir/value"
78
)
@@ -17,6 +18,8 @@ var (
1718
False = NewInt(types.I1, 0) // false
1819
)
1920

21+
// TODO: include metadata node in doc comment list of "Complex constants"?
22+
2023
// Constant is an LLVM IR constant; a value that is immutable at runtime, such
2124
// as an integer or floating-point literal, or the address of a function or
2225
// global variable.
@@ -27,57 +30,59 @@ var (
2730
//
2831
// https://llvm.org/docs/LangRef.html#simple-constants
2932
//
30-
// *constant.Int // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Int
31-
// *constant.Float // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Float
32-
// *constant.Null // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Null
33-
// *constant.NoneToken // https://pkg.go.dev/github.com/llir/llvm/ir/constant#NoneToken
33+
// - [*constant.Int]
34+
// - [*constant.Float]
35+
// - [*constant.Null]
36+
// - [*constant.NoneToken]
3437
//
3538
// # Complex constants
3639
//
3740
// https://llvm.org/docs/LangRef.html#complex-constants
3841
//
39-
// *constant.Struct // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Struct
40-
// *constant.Array // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Array
41-
// *constant.CharArray // https://pkg.go.dev/github.com/llir/llvm/ir/constant#CharArray
42-
// *constant.Vector // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Vector
43-
// *constant.ZeroInitializer // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ZeroInitializer
44-
// TODO: include metadata node?
42+
// - [*constant.Struct]
43+
// - [*constant.Array]
44+
// - [*constant.CharArray]
45+
// - [*constant.Vector]
46+
// - [*constant.ZeroInitializer]
4547
//
4648
// # Global variable and function addresses
4749
//
4850
// https://llvm.org/docs/LangRef.html#global-variable-and-function-addresses
4951
//
50-
// *ir.Global // https://pkg.go.dev/github.com/llir/llvm/ir#Global
51-
// *ir.Func // https://pkg.go.dev/github.com/llir/llvm/ir#Func
52-
// *ir.Alias // https://pkg.go.dev/github.com/llir/llvm/ir#Alias
53-
// *ir.IFunc // https://pkg.go.dev/github.com/llir/llvm/ir#IFunc
52+
// - [*ir.Global]
53+
// - [*ir.Func]
54+
// - [*ir.Alias]
55+
// - [*ir.IFunc]
5456
//
5557
// # Undefined values
5658
//
5759
// https://llvm.org/docs/LangRef.html#undefined-values
5860
//
59-
// *constant.Undef // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Undef
61+
// - [*constant.Undef]
6062
//
6163
// # Poison values
6264
//
6365
// https://llvm.org/docs/LangRef.html#poison-values
6466
//
65-
// *constant.Poison // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Poison
67+
// - [*constant.Poison]
6668
//
6769
// # Addresses of basic blocks
6870
//
6971
// https://llvm.org/docs/LangRef.html#addresses-of-basic-blocks
7072
//
71-
// *constant.BlockAddress // https://pkg.go.dev/github.com/llir/llvm/ir/constant#BlockAddress
73+
// - [*constant.BlockAddress]
7274
//
7375
// # Constant expressions
7476
//
7577
// https://llvm.org/docs/LangRef.html#constant-expressions
7678
//
77-
// constant.Expression // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Expression
79+
// - [constant.Expression]
7880
type Constant interface {
7981
value.Value
8082
// IsConstant ensures that only constants can be assigned to the
8183
// constant.Constant interface.
8284
IsConstant()
8385
}
86+
87+
// NOTE: used to have "ir.Foo" doc comments refer "github.com/llir/llvm/ir".
88+
var _ = &ir.Global{}

ir/constant/expression.go

+30-30
Original file line numberDiff line numberDiff line change
@@ -10,66 +10,66 @@ package constant
1010
//
1111
// https://llvm.org/docs/LangRef.html#constant-expressions
1212
//
13-
// *constant.ExprFNeg // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFNeg
13+
// - [*constant.ExprFNeg]
1414
//
1515
// # Binary expressions
1616
//
1717
// https://llvm.org/docs/LangRef.html#constant-expressions
1818
//
19-
// *constant.ExprAdd // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprAdd
20-
// *constant.ExprSub // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprSub
21-
// *constant.ExprMul // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprMul
19+
// - [*constant.ExprAdd]
20+
// - [*constant.ExprSub]
21+
// - [*constant.ExprMul]
2222
//
2323
// # Bitwise expressions
2424
//
2525
// https://llvm.org/docs/LangRef.html#constant-expressions
2626
//
27-
// *constant.ExprShl // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprShl
28-
// *constant.ExprLShr // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprLShr
29-
// *constant.ExprAShr // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprAShr
30-
// *constant.ExprAnd // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprAnd
31-
// *constant.ExprOr // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprOr
32-
// *constant.ExprXor // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprXor
27+
// - [*constant.ExprShl]
28+
// - [*constant.ExprLShr]
29+
// - [*constant.ExprAShr]
30+
// - [*constant.ExprAnd]
31+
// - [*constant.ExprOr]
32+
// - [*constant.ExprXor]
3333
//
3434
// # Vector expressions
3535
//
3636
// https://llvm.org/docs/LangRef.html#constant-expressions
3737
//
38-
// *constant.ExprExtractElement // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprExtractElement
39-
// *constant.ExprInsertElement // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprInsertElement
40-
// *constant.ExprShuffleVector // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprShuffleVector
38+
// - [*constant.ExprExtractElement]
39+
// - [*constant.ExprInsertElement]
40+
// - [*constant.ExprShuffleVector]
4141
//
4242
// # Memory expressions
4343
//
4444
// https://llvm.org/docs/LangRef.html#constant-expressions
4545
//
46-
// *constant.ExprGetElementPtr // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprGetElementPtr
46+
// - [*constant.ExprGetElementPtr]
4747
//
4848
// # Conversion expressions
4949
//
5050
// https://llvm.org/docs/LangRef.html#constant-expressions
5151
//
52-
// *constant.ExprTrunc // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprTrunc
53-
// *constant.ExprZExt // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprZExt
54-
// *constant.ExprSExt // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprSExt
55-
// *constant.ExprFPTrunc // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFPTrunc
56-
// *constant.ExprFPExt // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFPExt
57-
// *constant.ExprFPToUI // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFPToUI
58-
// *constant.ExprFPToSI // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFPToSI
59-
// *constant.ExprUIToFP // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprUIToFP
60-
// *constant.ExprSIToFP // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprSIToFP
61-
// *constant.ExprPtrToInt // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprPtrToInt
62-
// *constant.ExprIntToPtr // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprIntToPtr
63-
// *constant.ExprBitCast // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprBitCast
64-
// *constant.ExprAddrSpaceCast // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprAddrSpaceCast
52+
// - [*constant.ExprTrunc]
53+
// - [*constant.ExprZExt]
54+
// - [*constant.ExprSExt]
55+
// - [*constant.ExprFPTrunc]
56+
// - [*constant.ExprFPExt]
57+
// - [*constant.ExprFPToUI]
58+
// - [*constant.ExprFPToSI]
59+
// - [*constant.ExprUIToFP]
60+
// - [*constant.ExprSIToFP]
61+
// - [*constant.ExprPtrToInt]
62+
// - [*constant.ExprIntToPtr]
63+
// - [*constant.ExprBitCast]
64+
// - [*constant.ExprAddrSpaceCast]
6565
//
6666
// # Other expressions
6767
//
6868
// https://llvm.org/docs/LangRef.html#constant-expressions
6969
//
70-
// *constant.ExprICmp // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprICmp
71-
// *constant.ExprFCmp // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFCmp
72-
// *constant.ExprSelect // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprSelect
70+
// - [*constant.ExprICmp]
71+
// - [*constant.ExprFCmp]
72+
// - [*constant.ExprSelect]
7373
type Expression interface {
7474
Constant
7575
// IsExpression ensures that only constants expressions can be assigned to

0 commit comments

Comments
 (0)