compiler: remove //go:volatile support
Этот коммит содержится в:
родитель
e67506ee68
коммит
5cf7fba1a4
2 изменённых файлов: 2 добавлений и 37 удалений
|
@ -1086,12 +1086,7 @@ func (c *Compiler) parseInstr(frame *Frame, instr ssa.Instruction) {
|
||||||
// nothing to store
|
// nothing to store
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
store := c.builder.CreateStore(llvmVal, llvmAddr)
|
c.builder.CreateStore(llvmVal, llvmAddr)
|
||||||
valType := instr.Addr.Type().Underlying().(*types.Pointer).Elem()
|
|
||||||
if c.ir.IsVolatile(valType) {
|
|
||||||
// Volatile store, for memory-mapped registers.
|
|
||||||
store.SetVolatile(true)
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
c.addError(instr.Pos(), "unknown instruction: "+instr.String())
|
c.addError(instr.Pos(), "unknown instruction: "+instr.String())
|
||||||
}
|
}
|
||||||
|
@ -2505,7 +2500,7 @@ func (c *Compiler) parseUnOp(frame *Frame, unop *ssa.UnOp) (llvm.Value, error) {
|
||||||
return llvm.Value{}, c.makeError(unop.Pos(), "todo: unknown type for negate: "+unop.X.Type().Underlying().String())
|
return llvm.Value{}, c.makeError(unop.Pos(), "todo: unknown type for negate: "+unop.X.Type().Underlying().String())
|
||||||
}
|
}
|
||||||
case token.MUL: // *x, dereference pointer
|
case token.MUL: // *x, dereference pointer
|
||||||
valType := unop.X.Type().Underlying().(*types.Pointer).Elem()
|
unop.X.Type().Underlying().(*types.Pointer).Elem()
|
||||||
if c.targetData.TypeAllocSize(x.Type().ElementType()) == 0 {
|
if c.targetData.TypeAllocSize(x.Type().ElementType()) == 0 {
|
||||||
// zero-length data
|
// zero-length data
|
||||||
return c.getZeroValue(x.Type().ElementType()), nil
|
return c.getZeroValue(x.Type().ElementType()), nil
|
||||||
|
@ -2525,10 +2520,6 @@ func (c *Compiler) parseUnOp(frame *Frame, unop *ssa.UnOp) (llvm.Value, error) {
|
||||||
} else {
|
} else {
|
||||||
c.emitNilCheck(frame, x, "deref")
|
c.emitNilCheck(frame, x, "deref")
|
||||||
load := c.builder.CreateLoad(x, "")
|
load := c.builder.CreateLoad(x, "")
|
||||||
if c.ir.IsVolatile(valType) {
|
|
||||||
// Volatile load, for memory-mapped registers.
|
|
||||||
load.SetVolatile(true)
|
|
||||||
}
|
|
||||||
return load, nil
|
return load, nil
|
||||||
}
|
}
|
||||||
case token.XOR: // ^x, toggle all bits in integer
|
case token.XOR: // ^x, toggle all bits in integer
|
||||||
|
|
26
ir/ir.go
26
ir/ir.go
|
@ -100,9 +100,6 @@ func NewProgram(lprogram *loader.Program, mainPath string) *Program {
|
||||||
}
|
}
|
||||||
for _, spec := range decl.Specs {
|
for _, spec := range decl.Specs {
|
||||||
switch spec := spec.(type) {
|
switch spec := spec.(type) {
|
||||||
case *ast.TypeSpec: // decl.Tok == token.TYPE
|
|
||||||
id := pkgInfo.Pkg.Path() + "." + spec.Name.Name
|
|
||||||
comments[id] = decl.Doc
|
|
||||||
case *ast.ValueSpec: // decl.Tok == token.VAR
|
case *ast.ValueSpec: // decl.Tok == token.VAR
|
||||||
for _, name := range spec.Names {
|
for _, name := range spec.Names {
|
||||||
id := pkgInfo.Pkg.Path() + "." + name.Name
|
id := pkgInfo.Pkg.Path() + "." + name.Name
|
||||||
|
@ -432,29 +429,6 @@ func (g *Global) CName() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if this named type is annotated with the //go:volatile pragma,
|
|
||||||
// for volatile loads and stores.
|
|
||||||
func (p *Program) IsVolatile(t types.Type) bool {
|
|
||||||
if t, ok := t.(*types.Named); !ok {
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
if t.Obj().Pkg() == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
id := t.Obj().Pkg().Path() + "." + t.Obj().Name()
|
|
||||||
doc := p.comments[id]
|
|
||||||
if doc == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for _, line := range doc.List {
|
|
||||||
if strings.TrimSpace(line.Text) == "//go:volatile" {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get all methods of a type.
|
// Get all methods of a type.
|
||||||
func getAllMethods(prog *ssa.Program, typ types.Type) []*types.Selection {
|
func getAllMethods(prog *ssa.Program, typ types.Type) []*types.Selection {
|
||||||
ms := prog.MethodSets.MethodSet(typ)
|
ms := prog.MethodSets.MethodSet(typ)
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче