1 // Copyright 2019 The SwiftShader Authors. All Rights Reserved. 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 15 #include "Reactor.hpp" 16 17 // Implementation of intrinsics that are "emulated" - that is, 18 // implemented either in terms of Reactor code, or make use of 19 // rr::Call to C functions. These are typically slower than implementing 20 // in terms of direct calls to the JIT backend; however, provide a good 21 // starting point for implementing a new backend, or for when adding 22 // functionality to an existing backend is non-trivial. 23 24 namespace rr { 25 namespace emulated { 26 27 RValue<Float4> Gather(RValue<Pointer<Float>> base, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes = false); 28 RValue<Int4> Gather(RValue<Pointer<Int>> base, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes = false); 29 void Scatter(RValue<Pointer<Float>> base, RValue<Float4> val, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment); 30 void Scatter(RValue<Pointer<Int>> base, RValue<Int4> val, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment); 31 RValue<Float> Exp2(RValue<Float> x); 32 RValue<Float> Log2(RValue<Float> x); 33 RValue<Float4> Sin(RValue<Float4> x); 34 RValue<Float4> Cos(RValue<Float4> x); 35 RValue<Float4> Tan(RValue<Float4> x); 36 RValue<Float4> Asin(RValue<Float4> x); 37 RValue<Float4> Acos(RValue<Float4> x); 38 RValue<Float4> Atan(RValue<Float4> x); 39 RValue<Float4> Sinh(RValue<Float4> x); 40 RValue<Float4> Cosh(RValue<Float4> x); 41 RValue<Float4> Tanh(RValue<Float4> x); 42 RValue<Float4> Asinh(RValue<Float4> x); 43 RValue<Float4> Acosh(RValue<Float4> x); 44 RValue<Float4> Atanh(RValue<Float4> x); 45 RValue<Float4> Atan2(RValue<Float4> x, RValue<Float4> y); 46 RValue<Float4> Pow(RValue<Float4> x, RValue<Float4> y); 47 RValue<Float4> Exp(RValue<Float4> x); 48 RValue<Float4> Log(RValue<Float4> x); 49 RValue<Float4> Exp2(RValue<Float4> x); 50 RValue<Float4> Log2(RValue<Float4> x); 51 RValue<Int> MinAtomic(RValue<Pointer<Int>> x, RValue<Int> y, std::memory_order memoryOrder); 52 RValue<UInt> MinAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); 53 RValue<Int> MaxAtomic(RValue<Pointer<Int>> x, RValue<Int> y, std::memory_order memoryOrder); 54 RValue<UInt> MaxAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder); 55 RValue<Float4> FRem(RValue<Float4> lhs, RValue<Float4> rhs); 56 57 } // namespace emulated 58 } // namespace rr 59