MCPcopy
hub / github.com/tinygo-org/tinygo / AddStandardAttributes

Function AddStandardAttributes

transform/transform.go:23–38  ·  view source on GitHub ↗

AddStandardAttributes is a helper function to add standard function attributes to a function. For example, it adds optsize when requested from the -opt= compiler flag.

(fn llvm.Value, config *compileopts.Config)

Source from the content-addressed store, hash-verified

21// attributes to a function. For example, it adds optsize when requested from
22// the -opt= compiler flag.
23func AddStandardAttributes(fn llvm.Value, config *compileopts.Config) {
24 ctx := fn.Type().Context()
25 _, _, sizeLevel := config.OptLevel()
26 if sizeLevel >= 1 {
27 fn.AddFunctionAttr(ctx.CreateEnumAttribute(llvm.AttributeKindID("optsize"), 0))
28 }
29 if sizeLevel >= 2 {
30 fn.AddFunctionAttr(ctx.CreateEnumAttribute(llvm.AttributeKindID("minsize"), 0))
31 }
32 if config.CPU() != "" {
33 fn.AddFunctionAttr(ctx.CreateStringAttribute("target-cpu", config.CPU()))
34 }
35 if config.Features() != "" {
36 fn.AddFunctionAttr(ctx.CreateStringAttribute("target-features", config.Features()))
37 }
38}

Callers 3

BuildFunction · 0.92

Calls 5

OptLevelMethod · 0.80
CPUMethod · 0.80
FeaturesMethod · 0.80
ContextMethod · 0.65
TypeMethod · 0.45

Tested by

no test coverage detected