1// Copyright 2020 ConsenSys Software Inc. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package amd64 16 17func (f *FFAmd64) generateAdd() { 18 f.Comment("add(res, x, y *Element)") 19 20 stackSize := f.StackSize(f.NbWords*2, 0, 0) 21 registers := f.FnHeader("add", stackSize, 24) 22 defer f.AssertCleanStack(stackSize, 0) 23 24 // registers 25 x := registers.Pop() 26 y := registers.Pop() 27 t := registers.PopN(f.NbWords) 28 29 // t = x 30 f.MOVQ("x+8(FP)", x) 31 f.Mov(x, t) 32 registers.Push(x) 33 34 // t = t + y = x + y 35 f.MOVQ("y+16(FP)", y) 36 f.Add(y, t) 37 registers.Push(y) 38 39 // reduce t 40 f.Reduce(®isters, t) 41 42 r := registers.Pop() 43 f.MOVQ("res+0(FP)", r) 44 f.Mov(t, r) 45 46 f.RET() 47 48} 49