1//===- TernaryOp.h --------------------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#ifndef MCLD_SCRIPT_TERNARYOP_H_ 10#define MCLD_SCRIPT_TERNARYOP_H_ 11 12#include "mcld/Script/Operator.h" 13 14#include <cstddef> 15 16namespace mcld { 17 18class IntOperand; 19class Module; 20class Operand; 21class TargetLDBackend; 22 23/** \class TernaryOP 24 * \brief This class defines the interfaces to an binary operator token. 25 */ 26 27template <Operator::Type TYPE> 28class TernaryOp : public Operator { 29 private: 30 friend class Operator; 31 32 TernaryOp() : Operator(Operator::TERNARY, TYPE) { 33 m_pOperand[0] = m_pOperand[1] = m_pOperand[2] = NULL; 34 } 35 36 public: 37 ~TernaryOp() {} 38 39 IntOperand* eval(const Module& pModule, const TargetLDBackend& pBackend); 40 41 void appendOperand(Operand* pOperand) { 42 m_pOperand[m_Size++] = pOperand; 43 if (m_Size == 3) 44 m_Size = 0; 45 } 46 47 private: 48 size_t m_Size; 49 Operand* m_pOperand[3]; 50}; 51 52template <> 53IntOperand* TernaryOp<Operator::TERNARY_IF>::eval(const Module&, 54 const TargetLDBackend&); 55 56template <> 57IntOperand* TernaryOp<Operator::DATA_SEGMENT_ALIGN>::eval( 58 const Module&, 59 const TargetLDBackend&); 60 61} // namespace mcld 62 63#endif // MCLD_SCRIPT_TERNARYOP_H_ 64