Giter Club home page Giter Club logo

Comments (6)

dannypsnl avatar dannypsnl commented on August 23, 2024 1
	m := ir.NewModule()

	foo := m.NewTypeDef("foo", types.NewStruct(types.I32))
	_ = m.NewTypeDef("bar", types.NewStruct(foo))

	main := m.NewFunc("main", types.I32)

	{
		entry := main.NewBlock("")
		entry.NewRet(constant.NewInt(types.I32, 0))
	}

	fmt.Println(m)

output

%foo = type { i32 }
%bar = type { %foo }

define i32 @main() {
0:
	ret i32 0
}

from llvm.

dannypsnl avatar dannypsnl commented on August 23, 2024

From my understanding, embedded struct is a field that got an implicit name, so you insert reference to A and give a generated name.

from llvm.

wiltchamberian avatar wiltchamberian commented on August 23, 2024

yes, I understand, but how to write the code there, it is a type of types.Var, so what if I have a types.Struct?

from llvm.

dannypsnl avatar dannypsnl commented on August 23, 2024

I believe you can use the "variable" in Go as instance of "type"

from llvm.

wiltchamberian avatar wiltchamberian commented on August 23, 2024

in fact, not that easy. the variable in Go has type *types.Struct but the input needs to be a *types.Var, types.Var includes types.object and types.object include golang "Type", but not a types.Struct, so I have no idea about how to input the parameters. Or if you can write down the code.

from llvm.

dannypsnl avatar dannypsnl commented on August 23, 2024

You can also use types.NewPointer(foo) to get:

%foo = type { i32 }
%bar = type { %foo* }

define i32 @main() {
0:
	ret i32 0
}

from llvm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.