Пример #1
0
func (v *allocator) allocFunction(fn *ir.Function) {
	switch fn.CallConv() {
	case ir.CCallConv, ir.X86_StdCallConv:
		parPos := 8
		for _, par := range fn.Parameters() {
			v.locs[par] = &location{
				stackPos: parPos,
			}

			bytes := v.target.TypeSize(par.Type())
			if bytes%2 == 1 {
				bytes++
			}
			parPos += bytes
		}
	default:
		panic("x86 target does not support " + fn.CallConv().String())
	}

	for _, block := range fn.Blocks() {
		for _, instr := range block.Instrs() {
			if !instr.Type().IsVoid() {
				v.addValue(instr)
			}
		}
	}
}