|
|
/* A Bison parser, made by GNU Bison 2.4.1. */
|
/* A Bison parser, made by GNU Bison 2.4.1. */
|
|
|
/* Skeleton implementation for Bison LALR(1) parsers in C++
|
/* Skeleton implementation for Bison LALR(1) parsers in C++
|
|
|
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software
|
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software
|
Foundation, Inc.
|
Foundation, Inc.
|
|
|
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
(at your option) any later version.
|
(at your option) any later version.
|
|
|
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
GNU General Public License for more details.
|
GNU General Public License for more details.
|
|
|
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
/* As a special exception, you may create a larger work that contains
|
/* As a special exception, you may create a larger work that contains
|
part or all of the Bison parser skeleton and distribute that work
|
part or all of the Bison parser skeleton and distribute that work
|
under terms of your choice, so long as that work isn't itself a
|
under terms of your choice, so long as that work isn't itself a
|
parser generator using the skeleton or a modified version thereof
|
parser generator using the skeleton or a modified version thereof
|
as a parser skeleton. Alternatively, if you modify or redistribute
|
as a parser skeleton. Alternatively, if you modify or redistribute
|
the parser skeleton itself, you may (at your option) remove this
|
the parser skeleton itself, you may (at your option) remove this
|
special exception, which will cause the skeleton and the resulting
|
special exception, which will cause the skeleton and the resulting
|
Bison output files to be licensed under the GNU General Public
|
Bison output files to be licensed under the GNU General Public
|
License without this special exception.
|
License without this special exception.
|
|
|
This special exception was added by the Free Software Foundation in
|
This special exception was added by the Free Software Foundation in
|
version 2.2 of Bison. */
|
version 2.2 of Bison. */
|
|
|
|
|
/* First part of user declarations. */
|
/* First part of user declarations. */
|
|
|
|
|
/* Line 311 of lalr1.cc */
|
/* Line 311 of lalr1.cc */
|
#line 41 "parser.tab.c"
|
#line 41 "parser.tab.c"
|
|
|
|
|
#include "parser.tab.h"
|
#include "parser.tab.h"
|
|
|
/* User implementation prologue. */
|
/* User implementation prologue. */
|
|
|
|
|
/* Line 317 of lalr1.cc */
|
/* Line 317 of lalr1.cc */
|
#line 50 "parser.tab.c"
|
#line 50 "parser.tab.c"
|
/* Unqualified %code blocks. */
|
/* Unqualified %code blocks. */
|
|
|
/* Line 318 of lalr1.cc */
|
/* Line 318 of lalr1.cc */
|
#line 68 "parser.y"
|
#line 68 "parser.y"
|
|
|
#include "Instruction.h"
|
#include "Instruction.h"
|
#include <vector>
|
#include <vector>
|
Instruction I,tmpI;
|
Instruction I,tmpI;
|
|
|
std::vector< unsigned int > gBranchStack;
|
std::vector< unsigned int > gBranchStack;
|
static int gInsertedInstructions = 0;
|
static int gInsertedInstructions = 0;
|
static int gWhileLoopAddress = 0;
|
static int gWhileLoopAddress = 0;
|
#define FUNCTION_PARAM_START_REGION 4
|
#define FUNCTION_PARAM_START_REGION 4
|
#define FUNCTION_PARAM_LAST_REGION 10
|
#define FUNCTION_PARAM_LAST_REGION 10
|
std::map<std::string, unsigned int> gFunctionParameters;
|
std::map<std::string, unsigned int> gFunctionParameters;
|
std::map<std::string, unsigned int> gAutoVarMap;
|
std::map<std::string, unsigned int> gAutoVarMap;
|
std::map<std::string, unsigned int> gThreadMap; //Key: Symbol, value: start code addr
|
std::map<std::string, unsigned int> gThreadMap; //Key: Symbol, value: start code addr
|
bool gThreadScope = false;
|
bool gThreadScope = false;
|
#define AUTOVAR_START_REGION 9
|
#define AUTOVAR_START_REGION 9
|
#define THREAD_OFFSET 128
|
#define THREAD_OFFSET 128
|
unsigned int gExtraDestModifications = 0;
|
unsigned int gExtraDestModifications = 0;
|
unsigned int gAutoVarIndex = AUTOVAR_START_REGION;
|
unsigned int gAutoVarIndex = AUTOVAR_START_REGION;
|
unsigned int gThreadAutoVarIndex = THREAD_OFFSET;
|
unsigned int gThreadAutoVarIndex = THREAD_OFFSET;
|
unsigned int gFunctionParameterIndex = FUNCTION_PARAM_START_REGION;
|
unsigned int gFunctionParameterIndex = FUNCTION_PARAM_START_REGION;
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
unsigned int GetNextFunctionParamRegister()
|
unsigned int GetNextFunctionParamRegister()
|
{
|
{
|
unsigned Ret = gFunctionParameterIndex++;
|
unsigned Ret = gFunctionParameterIndex++;
|
return Ret;
|
return Ret;
|
}
|
}
|
|
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void AddFunctionParameter( std::string aVar, Theia::Parser::location_type yylloc)
|
void AddFunctionParameter( std::string aVar, Theia::Parser::location_type yylloc)
|
{
|
{
|
////std::cout << "Adding " << aVar << "\n";
|
////std::cout << "Adding " << aVar << "\n";
|
if (gFunctionParameterIndex+1 > FUNCTION_PARAM_LAST_REGION)
|
if (gFunctionParameterIndex+1 > FUNCTION_PARAM_LAST_REGION)
|
{
|
{
|
std::ostringstream ret;
|
std::ostringstream ret;
|
ret << "Cannot allocate more parameters '" << aVar << "' at line " << yylloc << " \n";
|
ret << "Cannot allocate more parameters '" << aVar << "' at line " << yylloc << " \n";
|
throw ret.str();
|
throw ret.str();
|
}
|
}
|
if (gFunctionParameters.find(aVar) != gFunctionParameters.end())
|
if (gFunctionParameters.find(aVar) != gFunctionParameters.end())
|
{
|
{
|
std::ostringstream ret;
|
std::ostringstream ret;
|
ret << "Parameter '" << aVar << "' at line " << yylloc << " is already defined\n";
|
ret << "Parameter '" << aVar << "' at line " << yylloc << " is already defined\n";
|
throw ret.str();
|
throw ret.str();
|
}
|
}
|
|
|
gFunctionParameters[ aVar ] = gFunctionParameterIndex++;
|
gFunctionParameters[ aVar ] = gFunctionParameterIndex++;
|
|
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
std::string GetRegisterFromFunctionParameter( std::string aVar )
|
std::string GetRegisterFromFunctionParameter( std::string aVar )
|
{
|
{
|
////std::cout << "Looking for " << aVar << "\n";
|
////std::cout << "Looking for " << aVar << "\n";
|
if (gFunctionParameters.find(aVar) == gFunctionParameters.end())
|
if (gFunctionParameters.find(aVar) == gFunctionParameters.end())
|
return "NULL";
|
return "NULL";
|
|
|
std::ostringstream ss;
|
std::ostringstream ss;
|
ss << gFunctionParameters[ aVar ];
|
ss << gFunctionParameters[ aVar ];
|
return ("R" + ss.str());
|
return ("R" + ss.str());
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
unsigned int GetCurretAutoVarFrameSize()
|
unsigned int GetCurretAutoVarFrameSize()
|
{
|
{
|
|
|
return gAutoVarMap.size();
|
return gAutoVarMap.size();
|
|
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
std::string GetRegisterFromAutoVar( std::string aVar, Theia::Parser::location_type yylloc )
|
std::string GetRegisterFromAutoVar( std::string aVar, Theia::Parser::location_type yylloc )
|
{
|
{
|
if (gAutoVarMap.find(aVar) == gAutoVarMap.end())
|
if (gAutoVarMap.find(aVar) == gAutoVarMap.end())
|
{
|
{
|
std::ostringstream ret;
|
std::ostringstream ret;
|
ret << "Undefined variable '" << aVar << "' at line " << yylloc << " \n";
|
ret << "Undefined variable '" << aVar << "' at line " << yylloc << " \n";
|
throw ret.str();
|
throw ret.str();
|
}
|
}
|
|
|
std::ostringstream ss;
|
std::ostringstream ss;
|
ss << gAutoVarMap[ aVar ];
|
ss << gAutoVarMap[ aVar ];
|
return ("R" + ss.str());
|
return ("R" + ss.str());
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
int GetCurrentLineNumber( const Theia::Parser::location_type &loc )
|
int GetCurrentLineNumber( const Theia::Parser::location_type &loc )
|
{
|
{
|
int ret = -1;
|
int ret = -1;
|
std::stringstream ss2;
|
std::stringstream ss2;
|
std::string where;
|
std::string where;
|
ss2 << loc;
|
ss2 << loc;
|
ss2 >> where;
|
ss2 >> where;
|
where.erase(where.find_first_of("."));
|
where.erase(where.find_first_of("."));
|
std::stringstream ss3;
|
std::stringstream ss3;
|
ss3 << where;
|
ss3 << where;
|
ss3 >> ret;
|
ss3 >> ret;
|
return ret;
|
return ret;
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
unsigned int AllocAutoVar( unsigned int aSize = 1)
|
unsigned int AllocAutoVar( unsigned int aSize = 1)
|
{
|
{
|
|
|
if (!gThreadScope)
|
if (!gThreadScope)
|
{
|
{
|
gAutoVarIndex += aSize;
|
gAutoVarIndex += aSize;
|
return gAutoVarIndex - (aSize-1);
|
return gAutoVarIndex - (aSize-1);
|
}else{
|
}else{
|
gThreadAutoVarIndex += aSize;
|
gThreadAutoVarIndex += aSize;
|
return (gThreadAutoVarIndex - (aSize-1));
|
return (gThreadAutoVarIndex - (aSize-1));
|
}
|
}
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void ClearFunctionParameterMap()
|
void ClearFunctionParameterMap()
|
{
|
{
|
gFunctionParameters.clear();
|
gFunctionParameters.clear();
|
gFunctionParameterIndex = FUNCTION_PARAM_START_REGION;
|
gFunctionParameterIndex = FUNCTION_PARAM_START_REGION;
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void ClearAutoVarMap()
|
void ClearAutoVarMap()
|
{
|
{
|
gAutoVarMap.clear();
|
gAutoVarMap.clear();
|
gAutoVarIndex = AUTOVAR_START_REGION;
|
gAutoVarIndex = AUTOVAR_START_REGION;
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
unsigned int gTempRegisterIndex = 1;
|
unsigned int gTempRegisterIndex = 1;
|
unsigned int GetFreeTempRegister( )
|
unsigned int GetFreeTempRegister( )
|
{
|
{
|
if (!gThreadScope)
|
if (!gThreadScope)
|
return gAutoVarIndex + (gTempRegisterIndex++);
|
return gAutoVarIndex + (gTempRegisterIndex++);
|
else
|
else
|
return gThreadAutoVarIndex + (gTempRegisterIndex++);
|
return gThreadAutoVarIndex + (gTempRegisterIndex++);
|
|
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void ResetTempRegisterIndex( void )
|
void ResetTempRegisterIndex( void )
|
{
|
{
|
|
|
gTempRegisterIndex = 1;
|
gTempRegisterIndex = 1;
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
bool IsSwizzled( std::string aSource)
|
bool IsSwizzled( std::string aSource)
|
{
|
{
|
if (aSource.find(".") != std::string::npos)
|
if (aSource.find(".") != std::string::npos)
|
return true;
|
return true;
|
else
|
else
|
return false;
|
return false;
|
}
|
}
|
|
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void SetSwizzleAndSign( unsigned int aSourceIndex, std::string aSwizzle, Instruction & I )
|
void SetSwizzleAndSign( unsigned int aSourceIndex, std::string aSwizzle, Instruction & I )
|
{
|
{
|
std::string Reg,X,Y,Z, junk;
|
std::string Reg,X,Y,Z, junk;
|
std::stringstream ss( aSwizzle );
|
std::stringstream ss( aSwizzle );
|
ss >> Reg >> junk >> X >> Y >> Z;
|
ss >> Reg >> junk >> X >> Y >> Z;
|
|
|
|
|
if (aSourceIndex == 1)
|
if (aSourceIndex == 1)
|
{
|
{
|
if (X == "X") { I.SetSrc1SwizzleX(SWX_X); }
|
if (X == "X") { I.SetSrc1SwizzleX(SWX_X); }
|
if (X == "Y") { I.SetSrc1SwizzleX(SWX_Y); }
|
if (X == "Y") { I.SetSrc1SwizzleX(SWX_Y); }
|
if (X == "Z") { I.SetSrc1SwizzleX(SWX_Z); }
|
if (X == "Z") { I.SetSrc1SwizzleX(SWX_Z); }
|
if (X == "-X") { I.SetSrc1SignX( true ); I.SetSrc1SwizzleX(SWX_X); }
|
if (X == "-X") { I.SetSrc1SignX( true ); I.SetSrc1SwizzleX(SWX_X); }
|
if (X == "-Y") { I.SetSrc1SignX( true ); I.SetSrc1SwizzleX(SWX_Y); }
|
if (X == "-Y") { I.SetSrc1SignX( true ); I.SetSrc1SwizzleX(SWX_Y); }
|
if (X == "-Z") { I.SetSrc1SignX( true ); I.SetSrc1SwizzleX(SWX_Z); }
|
if (X == "-Z") { I.SetSrc1SignX( true ); I.SetSrc1SwizzleX(SWX_Z); }
|
|
|
if (Y == "X") { I.SetSrc1SwizzleY(SWY_X); }
|
if (Y == "X") { I.SetSrc1SwizzleY(SWY_X); }
|
if (Y == "Y") { I.SetSrc1SwizzleY(SWY_Y); }
|
if (Y == "Y") { I.SetSrc1SwizzleY(SWY_Y); }
|
if (Y == "Z") { I.SetSrc1SwizzleY(SWY_Z); }
|
if (Y == "Z") { I.SetSrc1SwizzleY(SWY_Z); }
|
if (Y == "-X") { I.SetSrc1SignY( true ); I.SetSrc1SwizzleY(SWY_X); }
|
if (Y == "-X") { I.SetSrc1SignY( true ); I.SetSrc1SwizzleY(SWY_X); }
|
if (Y == "-Y") { I.SetSrc1SignY( true ); I.SetSrc1SwizzleY(SWY_Y); }
|
if (Y == "-Y") { I.SetSrc1SignY( true ); I.SetSrc1SwizzleY(SWY_Y); }
|
if (Y == "-Z") { I.SetSrc1SignY( true ); I.SetSrc1SwizzleY(SWY_Z); }
|
if (Y == "-Z") { I.SetSrc1SignY( true ); I.SetSrc1SwizzleY(SWY_Z); }
|
|
|
if (Z == "X") { I.SetSrc1SwizzleZ(SWZ_X); }
|
if (Z == "X") { I.SetSrc1SwizzleZ(SWZ_X); }
|
if (Z == "Y") { I.SetSrc1SwizzleZ(SWZ_Y); }
|
if (Z == "Y") { I.SetSrc1SwizzleZ(SWZ_Y); }
|
if (Z == "Z") { I.SetSrc1SwizzleZ(SWZ_Z); }
|
if (Z == "Z") { I.SetSrc1SwizzleZ(SWZ_Z); }
|
if (Z == "-X") { I.SetSrc1SignZ( true ); I.SetSrc1SwizzleZ(SWZ_X); }
|
if (Z == "-X") { I.SetSrc1SignZ( true ); I.SetSrc1SwizzleZ(SWZ_X); }
|
if (Z == "-Y") { I.SetSrc1SignZ( true ); I.SetSrc1SwizzleZ(SWZ_Y); }
|
if (Z == "-Y") { I.SetSrc1SignZ( true ); I.SetSrc1SwizzleZ(SWZ_Y); }
|
if (Z == "-Z") { I.SetSrc1SignZ( true ); I.SetSrc1SwizzleZ(SWZ_Z); }
|
if (Z == "-Z") { I.SetSrc1SignZ( true ); I.SetSrc1SwizzleZ(SWZ_Z); }
|
} else {
|
} else {
|
if (X == "X") { I.SetSrc0SwizzleX(SWX_X); }
|
if (X == "X") { I.SetSrc0SwizzleX(SWX_X); }
|
if (X == "Y") { I.SetSrc0SwizzleX(SWX_Y); }
|
if (X == "Y") { I.SetSrc0SwizzleX(SWX_Y); }
|
if (X == "Z") { I.SetSrc0SwizzleX(SWX_Z); }
|
if (X == "Z") { I.SetSrc0SwizzleX(SWX_Z); }
|
if (X == "-X") { I.SetSrc0SignX( true ); I.SetSrc0SwizzleX(SWX_X); }
|
if (X == "-X") { I.SetSrc0SignX( true ); I.SetSrc0SwizzleX(SWX_X); }
|
if (X == "-Y") { I.SetSrc0SignX( true ); I.SetSrc0SwizzleX(SWX_Y); }
|
if (X == "-Y") { I.SetSrc0SignX( true ); I.SetSrc0SwizzleX(SWX_Y); }
|
if (X == "-Z") { I.SetSrc0SignX( true ); I.SetSrc0SwizzleX(SWX_Z); }
|
if (X == "-Z") { I.SetSrc0SignX( true ); I.SetSrc0SwizzleX(SWX_Z); }
|
|
|
if (Y == "X") { I.SetSrc0SwizzleY(SWY_X); }
|
if (Y == "X") { I.SetSrc0SwizzleY(SWY_X); }
|
if (Y == "Y") { I.SetSrc0SwizzleY(SWY_Y); }
|
if (Y == "Y") { I.SetSrc0SwizzleY(SWY_Y); }
|
if (Y == "Z") { I.SetSrc0SwizzleY(SWY_Z); }
|
if (Y == "Z") { I.SetSrc0SwizzleY(SWY_Z); }
|
if (Y == "-X") { I.SetSrc0SignY( true ); I.SetSrc0SwizzleY(SWY_X); }
|
if (Y == "-X") { I.SetSrc0SignY( true ); I.SetSrc0SwizzleY(SWY_X); }
|
if (Y == "-Y") { I.SetSrc0SignY( true ); I.SetSrc0SwizzleY(SWY_Y); }
|
if (Y == "-Y") { I.SetSrc0SignY( true ); I.SetSrc0SwizzleY(SWY_Y); }
|
if (Y == "-Z") { I.SetSrc0SignY( true ); I.SetSrc0SwizzleY(SWY_Z); }
|
if (Y == "-Z") { I.SetSrc0SignY( true ); I.SetSrc0SwizzleY(SWY_Z); }
|
|
|
if (Z == "X") { I.SetSrc0SwizzleZ(SWZ_X); }
|
if (Z == "X") { I.SetSrc0SwizzleZ(SWZ_X); }
|
if (Z == "Y") { I.SetSrc0SwizzleZ(SWZ_Y); }
|
if (Z == "Y") { I.SetSrc0SwizzleZ(SWZ_Y); }
|
if (Z == "Z") { I.SetSrc0SwizzleZ(SWZ_Z); }
|
if (Z == "Z") { I.SetSrc0SwizzleZ(SWZ_Z); }
|
if (Z == "-X") { I.SetSrc0SignZ( true ); I.SetSrc0SwizzleZ(SWZ_X); }
|
if (Z == "-X") { I.SetSrc0SignZ( true ); I.SetSrc0SwizzleZ(SWZ_X); }
|
if (Z == "-Y") { I.SetSrc0SignZ( true ); I.SetSrc0SwizzleZ(SWZ_Y); }
|
if (Z == "-Y") { I.SetSrc0SignZ( true ); I.SetSrc0SwizzleZ(SWZ_Y); }
|
if (Z == "-Z") { I.SetSrc0SignZ( true ); I.SetSrc0SwizzleZ(SWZ_Z); }
|
if (Z == "-Z") { I.SetSrc0SignZ( true ); I.SetSrc0SwizzleZ(SWZ_Z); }
|
}
|
}
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void StoreReturnAddress( std::vector<Instruction> & aInstructions, Theia::Parser::location_type & yylloc )
|
void StoreReturnAddress( std::vector<Instruction> & aInstructions, Theia::Parser::location_type & yylloc )
|
{
|
{
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "store return address**";
|
I.mComment = "store return address**";
|
I.SetImm( aInstructions.size()+4 );
|
I.SetImm( aInstructions.size()+4 );
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetDestinationAddress( RETURN_ADDRESS_REGISTER );
|
I.SetDestinationAddress( RETURN_ADDRESS_REGISTER );
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
aInstructions.push_back( I );
|
aInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void SavePreviousFramePointer( std::vector<Instruction> & aInstructions )
|
void SavePreviousFramePointer( std::vector<Instruction> & aInstructions )
|
{
|
{
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "store current frame offset";
|
I.mComment = "store current frame offset";
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetSrc1Address(SPR_CONTROL_REGISTER);
|
I.SetSrc1Address(SPR_CONTROL_REGISTER);
|
I.SetSrc1SwizzleX(SWX_X);
|
I.SetSrc1SwizzleX(SWX_X);
|
I.SetSrc1SwizzleY(SWY_X);
|
I.SetSrc1SwizzleY(SWY_X);
|
I.SetSrc1SwizzleZ(SWZ_X);
|
I.SetSrc1SwizzleZ(SWZ_X);
|
I.SetSrc0Address(0);
|
I.SetSrc0Address(0);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
aInstructions.push_back( I );
|
aInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void SetIndexRegister( unsigned int aIndex, std::vector<Instruction> & aInstructions )
|
void SetIndexRegister( unsigned int aIndex, std::vector<Instruction> & aInstructions )
|
{
|
{
|
Instruction Tmp;
|
Instruction Tmp;
|
Tmp.SetCode( EOPERATION_ADD );
|
Tmp.SetCode( EOPERATION_ADD );
|
Tmp.mComment = "store array index register";
|
Tmp.mComment = "store array index register";
|
Tmp.SetWriteChannel(ECHANNEL_Z);
|
Tmp.SetWriteChannel(ECHANNEL_Z);
|
Tmp.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
Tmp.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
Tmp.SetSrc1Address( aIndex );
|
Tmp.SetSrc1Address( aIndex );
|
Tmp.SetSrc1Displace( true );
|
Tmp.SetSrc1Displace( true );
|
Tmp.SetSrc1SwizzleX(SWX_X);
|
Tmp.SetSrc1SwizzleX(SWX_X);
|
Tmp.SetSrc1SwizzleY(SWY_X);
|
Tmp.SetSrc1SwizzleY(SWY_X);
|
Tmp.SetSrc1SwizzleZ(SWZ_X);
|
Tmp.SetSrc1SwizzleZ(SWZ_X);
|
Tmp.SetSrc0Address(0);
|
Tmp.SetSrc0Address(0);
|
Tmp.SetSrc0SwizzleX(SWX_X);
|
Tmp.SetSrc0SwizzleX(SWX_X);
|
Tmp.SetSrc0SwizzleY(SWY_X);
|
Tmp.SetSrc0SwizzleY(SWY_X);
|
Tmp.SetSrc0SwizzleZ(SWZ_X);
|
Tmp.SetSrc0SwizzleZ(SWZ_X);
|
//Tmp.SetImm( aIndex );
|
//Tmp.SetImm( aIndex );
|
//Tmp.SetDestZero( true );
|
//Tmp.SetDestZero( true );
|
aInstructions.push_back( Tmp );
|
aInstructions.push_back( Tmp );
|
|
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void UpdateFramePointer( std::vector<Instruction> & aInstructions )
|
void UpdateFramePointer( std::vector<Instruction> & aInstructions )
|
{
|
{
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "displace next frame offset by the number of auto variables in current frame";
|
I.mComment = "displace next frame offset by the number of auto variables in current frame";
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetImm( GetCurretAutoVarFrameSize() );
|
I.SetImm( GetCurretAutoVarFrameSize() );
|
I.SetDestZero( false );
|
I.SetDestZero( false );
|
aInstructions.push_back( I );
|
aInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void CallFunction( std::string aFunctionName, std::vector<Instruction> & aInstructions, std::map<std::string,unsigned int> & aSymbolMap)
|
void CallFunction( std::string aFunctionName, std::vector<Instruction> & aInstructions, std::map<std::string,unsigned int> & aSymbolMap)
|
{
|
{
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "call the function";
|
I.mComment = "call the function";
|
I.SetBranchFlag( true );
|
I.SetBranchFlag( true );
|
I.SetBranchType( EBRANCH_ALWAYS );
|
I.SetBranchType( EBRANCH_ALWAYS );
|
//Now do the branch
|
//Now do the branch
|
if (aSymbolMap.find(aFunctionName) == aSymbolMap.end())
|
if (aSymbolMap.find(aFunctionName) == aSymbolMap.end())
|
I.SetDestinationSymbol( "@"+aFunctionName );
|
I.SetDestinationSymbol( "@"+aFunctionName );
|
else
|
else
|
I.SetDestinationAddress( aSymbolMap[ aFunctionName ] );
|
I.SetDestinationAddress( aSymbolMap[ aFunctionName ] );
|
|
|
aInstructions.push_back( I );
|
aInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void SetDestinationFromRegister( std::string aDestination, Instruction & aInst, bool Imm )
|
void SetDestinationFromRegister( std::string aDestination, Instruction & aInst, bool Imm )
|
{
|
{
|
//Look for displament addressing mode
|
//Look for displament addressing mode
|
|
|
if (aDestination.find("OFFSET") != std::string::npos)
|
if (aDestination.find("OFFSET") != std::string::npos)
|
{
|
{
|
aDestination.erase(aDestination.find("OFFSET"));
|
aDestination.erase(aDestination.find("OFFSET"));
|
////std::cout << "^_^ left_hand_side " << Destination << "\n";
|
////std::cout << "^_^ left_hand_side " << Destination << "\n";
|
if (Imm == true)
|
if (Imm == true)
|
aInst.SetSrc0Displace( true ); //When Imm == 0, then setting this makes offset
|
aInst.SetSrc0Displace( true ); //When Imm == 0, then setting this makes offset
|
else
|
else
|
aInst.SetDestZero( true ); //When Imm != 0, DestZero means DST = DSTINDEX + offset
|
aInst.SetDestZero( true ); //When Imm != 0, DestZero means DST = DSTINDEX + offset
|
}
|
}
|
if (aDestination.find(".") != std::string::npos)
|
if (aDestination.find(".") != std::string::npos)
|
{
|
{
|
aInst.ClearWriteChannel();
|
aInst.ClearWriteChannel();
|
if (aDestination.find("x") != std::string::npos)
|
if (aDestination.find("x") != std::string::npos)
|
aInst.SetWriteChannel(ECHANNEL_X);
|
aInst.SetWriteChannel(ECHANNEL_X);
|
if (aDestination.find("y") != std::string::npos)
|
if (aDestination.find("y") != std::string::npos)
|
aInst.SetWriteChannel(ECHANNEL_Y);
|
aInst.SetWriteChannel(ECHANNEL_Y);
|
if (aDestination.find("z") != std::string::npos)
|
if (aDestination.find("z") != std::string::npos)
|
aInst.SetWriteChannel(ECHANNEL_Z);
|
aInst.SetWriteChannel(ECHANNEL_Z);
|
|
|
aDestination.erase(aDestination.find("."));
|
aDestination.erase(aDestination.find("."));
|
|
|
}
|
}
|
aInst.SetDestinationAddress( atoi(aDestination.c_str()+1) );
|
aInst.SetDestinationAddress( atoi(aDestination.c_str()+1) );
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void PopulateSourceRegisters( std::string a1, std::string a2, Instruction & I, std::vector<Instruction> & aInstructions )
|
void PopulateSourceRegisters( std::string a1, std::string a2, Instruction & I, std::vector<Instruction> & aInstructions )
|
{
|
{
|
|
|
|
|
if ( a1.find("R") == std::string::npos )
|
if ( a1.find("R") == std::string::npos )
|
{
|
{
|
//This is for constants
|
//This is for constants
|
unsigned int ImmediateValue;
|
unsigned int ImmediateValue;
|
std::string StringHex = a1;
|
std::string StringHex = a1;
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
I.SetImm( ImmediateValue );
|
I.SetImm( ImmediateValue );
|
} else {
|
} else {
|
|
|
|
|
|
|
if (a1.find("array_element") != std::string::npos)
|
if (a1.find("array_element") != std::string::npos)
|
{
|
{
|
|
|
|
|
std::string Index = a1.substr(a1.find("array_element"));
|
std::string Index = a1.substr(a1.find("array_element"));
|
////std::cout << "XXXXX " << Index << "\n\n\n";
|
////std::cout << "XXXXX " << Index << "\n\n\n";
|
Index = Index.substr(Index.find_first_not_of("array_element R"));
|
Index = Index.substr(Index.find_first_not_of("array_element R"));
|
////std::cout << "XXXXX " << Index << "\n\n\n";
|
////std::cout << "XXXXX " << Index << "\n\n\n";
|
SetIndexRegister( atoi(Index.c_str()), aInstructions );
|
SetIndexRegister( atoi(Index.c_str()), aInstructions );
|
a1.erase(a1.find("array_element"));
|
a1.erase(a1.find("array_element"));
|
I.SetSrc0Displace( true );
|
I.SetSrc0Displace( true );
|
I.SetSrc1Displace( true );
|
I.SetSrc1Displace( true );
|
I.SetImmBit( true );
|
I.SetImmBit( true );
|
}
|
}
|
//Look for displament addressing mode
|
//Look for displament addressing mode
|
else if (a1.find("OFFSET") != std::string::npos)
|
else if (a1.find("OFFSET") != std::string::npos)
|
{
|
{
|
a1.erase(a1.find("OFFSET"));
|
a1.erase(a1.find("OFFSET"));
|
////std::cout << "^_^ a1" << a1 << "\n";
|
////std::cout << "^_^ a1" << a1 << "\n";
|
I.SetSrc1Displace( true ); //When Imm != 0, DestZero means DST = DSTINDEX + offset
|
I.SetSrc1Displace( true ); //When Imm != 0, DestZero means DST = DSTINDEX + offset
|
}
|
}
|
|
|
std::string Src1 = a1;
|
std::string Src1 = a1;
|
if (IsSwizzled( Src1 ))
|
if (IsSwizzled( Src1 ))
|
{
|
{
|
SetSwizzleAndSign( 1, Src1, I );
|
SetSwizzleAndSign( 1, Src1, I );
|
Src1.erase(Src1.find("."));
|
Src1.erase(Src1.find("."));
|
}
|
}
|
I.SetSrc1Address( atoi( Src1.c_str()+1 ) );
|
I.SetSrc1Address( atoi( Src1.c_str()+1 ) );
|
}
|
}
|
|
|
if ( a2.find("R") == std::string::npos)
|
if ( a2.find("R") == std::string::npos)
|
{
|
{
|
} else {
|
} else {
|
|
|
|
|
|
|
//Look for displament addressing mode
|
//Look for displament addressing mode
|
if (a2.find("OFFSET") != std::string::npos)
|
if (a2.find("OFFSET") != std::string::npos)
|
{
|
{
|
a2.erase(a2.find("OFFSET"));
|
a2.erase(a2.find("OFFSET"));
|
////std::cout << "^_^ a2 " << a2 << "\n";
|
////std::cout << "^_^ a2 " << a2 << "\n";
|
I.SetSrc0Displace( true ); //When Imm != 0, DestZero means DST = DSTINDEX + offset
|
I.SetSrc0Displace( true ); //When Imm != 0, DestZero means DST = DSTINDEX + offset
|
}
|
}
|
|
|
std::string Src0 = a2;
|
std::string Src0 = a2;
|
if (IsSwizzled( Src0 ))
|
if (IsSwizzled( Src0 ))
|
{
|
{
|
SetSwizzleAndSign( 0, Src0, I );
|
SetSwizzleAndSign( 0, Src0, I );
|
Src0.erase(Src0.find("."));
|
Src0.erase(Src0.find("."));
|
}
|
}
|
I.SetSrc0Address( atoi( Src0.c_str()+1 ) );
|
I.SetSrc0Address( atoi( Src0.c_str()+1 ) );
|
}
|
}
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void ClearNextFunctionParamRegister()
|
void ClearNextFunctionParamRegister()
|
{
|
{
|
gFunctionParameterIndex = FUNCTION_PARAM_START_REGION;
|
gFunctionParameterIndex = FUNCTION_PARAM_START_REGION;
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void AddFunctionInputList( std::string aVar, std::vector<Instruction> & aInstructions,Theia::Parser::location_type yylloc)
|
void AddFunctionInputList( std::string aVar, std::vector<Instruction> & aInstructions,Theia::Parser::location_type yylloc)
|
{
|
{
|
//Get the value from the variable
|
//Get the value from the variable
|
|
DCOUT << "Calling AddFunctionInputList input arg: " << aVar << " \n";
|
//Copy the value into function parameter register
|
//Copy the value into function parameter register
|
unsigned FunctionParamReg = GetNextFunctionParamRegister();
|
unsigned FunctionParamReg = GetNextFunctionParamRegister();
|
I.Clear();
|
I.Clear();
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "copy the value into function parameter register";
|
I.mComment = "copy the value into function parameter register";
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
//I.SetDestZero( true ); //When Imm != 0, DestZero means DST = DSTINDEX + offset
|
//I.SetDestZero( true ); //When Imm != 0, DestZero means DST = DSTINDEX + offset
|
I.SetDestinationAddress( FunctionParamReg );
|
I.SetDestinationAddress( FunctionParamReg );
|
|
|
if (aVar.find("R") != std::string::npos)
|
if (aVar.find("R") != std::string::npos)
|
{
|
{
|
if (aVar.find("OFFSET") != std::string::npos)
|
if (aVar.find("OFFSET") != std::string::npos)
|
{
|
{
|
I.SetSrc1Displace( true );
|
I.SetSrc1Displace( true );
|
aVar.erase(aVar.find("OFFSET"));
|
aVar.erase(aVar.find("OFFSET"));
|
}
|
}
|
I.SetSrc1Address(atoi(aVar.c_str()+1));
|
I.SetSrc1Address(atoi(aVar.c_str()+1));
|
|
I.SetSrc1SwizzleX(SWX_X);
|
|
I.SetSrc1SwizzleY(SWY_Y);
|
|
I.SetSrc1SwizzleZ(SWZ_Z);
|
|
I.SetSrc0Address(0);
|
|
I.SetSrc0SwizzleX(SWX_X);
|
|
I.SetSrc0SwizzleY(SWY_X);
|
|
I.SetSrc0SwizzleZ(SWZ_X);
|
|
aInstructions.push_back( I );
|
|
I.Clear();
|
return;
|
return;
|
}
|
}
|
std::string Reg = GetRegisterFromFunctionParameter( aVar );
|
std::string Reg = GetRegisterFromFunctionParameter( aVar );
|
if (Reg == "NULL")
|
if (Reg == "NULL")
|
{
|
{
|
Reg = GetRegisterFromAutoVar( aVar, yylloc );
|
Reg = GetRegisterFromAutoVar( aVar, yylloc );
|
I.SetSrc1Address(atoi(Reg.c_str()+1));
|
I.SetSrc1Address(atoi(Reg.c_str()+1));
|
I.SetSrc1Displace( true );
|
I.SetSrc1Displace( true );
|
} else {
|
} else {
|
I.SetSrc1Address(atoi(Reg.c_str()+1));
|
I.SetSrc1Address(atoi(Reg.c_str()+1));
|
I.SetSrc1Displace( false );
|
I.SetSrc1Displace( false );
|
}
|
}
|
|
|
|
|
|
|
I.SetSrc1SwizzleX(SWX_X);
|
I.SetSrc1SwizzleX(SWX_X);
|
I.SetSrc1SwizzleY(SWY_Y);
|
I.SetSrc1SwizzleY(SWY_Y);
|
I.SetSrc1SwizzleZ(SWZ_Z);
|
I.SetSrc1SwizzleZ(SWZ_Z);
|
I.SetSrc0Address(0);
|
I.SetSrc0Address(0);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
aInstructions.push_back( I );
|
aInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
void SetExpressionDestination( std::string aStringDestination, Instruction & I )
|
void SetExpressionDestination( std::string aStringDestination, Instruction & I )
|
{
|
{
|
std::string Destination = aStringDestination;
|
std::string Destination = aStringDestination;
|
|
|
//Look for indirect addressing
|
//Look for indirect addressing
|
if (Destination.find("INDEX") != std::string::npos)
|
if (Destination.find("INDEX") != std::string::npos)
|
{
|
{
|
|
|
std::string IndexRegister = Destination.substr(Destination.find("INDEX")+5);
|
std::string IndexRegister = Destination.substr(Destination.find("INDEX")+5);
|
Destination.erase(Destination.find("INDEX"));
|
Destination.erase(Destination.find("INDEX"));
|
I.SetImm( 0 );
|
I.SetImm( 0 );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
|
|
if (Destination.find(".") != std::string::npos)
|
if (Destination.find(".") != std::string::npos)
|
{
|
{
|
I.ClearWriteChannel();
|
I.ClearWriteChannel();
|
if (Destination.find("x") != std::string::npos)
|
if (Destination.find("x") != std::string::npos)
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
if (Destination.find("y") != std::string::npos)
|
if (Destination.find("y") != std::string::npos)
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetWriteChannel(ECHANNEL_Y);
|
if (Destination.find("z") != std::string::npos)
|
if (Destination.find("z") != std::string::npos)
|
I.SetWriteChannel(ECHANNEL_Z);
|
I.SetWriteChannel(ECHANNEL_Z);
|
Destination.erase(Destination.find("."));
|
Destination.erase(Destination.find("."));
|
|
|
}
|
}
|
|
|
I.SetDestinationAddress( atoi(Destination.c_str()+1) );
|
I.SetDestinationAddress( atoi(Destination.c_str()+1) );
|
|
|
} else {
|
} else {
|
|
|
//Look for displament addressing mode
|
//Look for displament addressing mode
|
if (Destination.find("OFFSET") != std::string::npos)
|
if (Destination.find("OFFSET") != std::string::npos)
|
{
|
{
|
Destination.erase(Destination.find("OFFSET"));
|
Destination.erase(Destination.find("OFFSET"));
|
I.SetDestZero( true ); //When Imm != 0, DestZero means DST = DSTINDEX + offset
|
I.SetDestZero( true ); //When Imm != 0, DestZero means DST = DSTINDEX + offset
|
}
|
}
|
if (Destination.find(".") != std::string::npos)
|
if (Destination.find(".") != std::string::npos)
|
{
|
{
|
I.ClearWriteChannel();
|
I.ClearWriteChannel();
|
if (Destination.find("x") != std::string::npos)
|
if (Destination.find("x") != std::string::npos)
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
if (Destination.find("y") != std::string::npos)
|
if (Destination.find("y") != std::string::npos)
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetWriteChannel(ECHANNEL_Y);
|
if (Destination.find("z") != std::string::npos)
|
if (Destination.find("z") != std::string::npos)
|
I.SetWriteChannel(ECHANNEL_Z);
|
I.SetWriteChannel(ECHANNEL_Z);
|
|
|
Destination.erase(Destination.find("."));
|
Destination.erase(Destination.find("."));
|
|
|
}
|
}
|
I.SetDestinationAddress( atoi(Destination.c_str()+1) );
|
I.SetDestinationAddress( atoi(Destination.c_str()+1) );
|
|
|
|
|
|
|
}
|
}
|
}
|
}
|
|
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
bool SourceNull( std::string aSource )
|
bool SourceNull( std::string aSource )
|
{
|
{
|
if (aSource == "NULL")
|
if (aSource == "NULL")
|
return true;
|
return true;
|
|
|
return false;
|
return false;
|
}
|
}
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
|
|
void PopulateInstruction( std::string aDestination, std::string aSource1, std::string aSource0, Instruction & I, Theia::Parser::location_type yylloc, bool aHasLiteral = false, unsigned int aLiteral = 0)
|
void PopulateInstruction( std::string aDestination, std::string aSource1, std::string aSource0, Instruction & I, Theia::Parser::location_type yylloc, bool aHasLiteral = false, unsigned int aLiteral = 0)
|
{
|
{
|
|
|
|
|
bool DestinationHasOffset = false;
|
bool DestinationHasOffset = false;
|
bool DetinationHasIndex = false;
|
bool DetinationHasIndex = false;
|
bool Source0HasOffset = false;
|
bool Source0HasOffset = false;
|
bool Source1HasOffset = false;
|
bool Source1HasOffset = false;
|
bool Source1HasIndex = false;
|
bool Source1HasIndex = false;
|
bool Source0HasIndex = false;
|
bool Source0HasIndex = false;
|
|
|
|
|
if (aDestination.find("INDEX") != std::string::npos)
|
if (aDestination.find("INDEX") != std::string::npos)
|
{
|
{
|
std::string ArrayIndex = aDestination.substr(aDestination.find("INDEX")+5);
|
std::string ArrayIndex = aDestination.substr(aDestination.find("INDEX")+5);
|
aSource1 = ArrayIndex;
|
aSource1 = ArrayIndex;
|
DetinationHasIndex = true;
|
DetinationHasIndex = true;
|
|
|
}
|
}
|
|
|
if (aSource1.find("INDEX") != std::string::npos)
|
if (aSource1.find("INDEX") != std::string::npos)
|
Source1HasIndex = true;
|
Source1HasIndex = true;
|
|
|
if (aSource0.find("INDEX") != std::string::npos)
|
if (aSource0.find("INDEX") != std::string::npos)
|
Source0HasIndex = true;
|
Source0HasIndex = true;
|
|
|
if (aDestination.find("OFFSET") != std::string::npos)
|
if (aDestination.find("OFFSET") != std::string::npos)
|
DestinationHasOffset = true;
|
DestinationHasOffset = true;
|
|
|
if (aSource0.find("OFFSET") != std::string::npos)
|
if (aSource0.find("OFFSET") != std::string::npos)
|
Source0HasOffset = true;
|
Source0HasOffset = true;
|
|
|
if (aSource1.find("OFFSET") != std::string::npos)
|
if (aSource1.find("OFFSET") != std::string::npos)
|
Source1HasOffset = true;
|
Source1HasOffset = true;
|
|
|
if (IsSwizzled( aSource1 ))
|
if (IsSwizzled( aSource1 ))
|
SetSwizzleAndSign( 1, aSource1, I );
|
SetSwizzleAndSign( 1, aSource1, I );
|
I.SetSrc1Address( atoi( aSource1.c_str()+1 ) );
|
I.SetSrc1Address( atoi( aSource1.c_str()+1 ) );
|
|
|
if (IsSwizzled( aSource0 ))
|
if (IsSwizzled( aSource0 ))
|
SetSwizzleAndSign( 0, aSource0, I );
|
SetSwizzleAndSign( 0, aSource0, I );
|
I.SetSrc0Address( atoi( aSource0.c_str()+1 ) );
|
I.SetSrc0Address( atoi( aSource0.c_str()+1 ) );
|
|
|
|
|
|
|
//Fisrt take care of the destination write channel
|
//Fisrt take care of the destination write channel
|
if (aDestination.find(".") != std::string::npos)
|
if (aDestination.find(".") != std::string::npos)
|
{
|
{
|
I.ClearWriteChannel();
|
I.ClearWriteChannel();
|
if (aDestination.find("x") != std::string::npos)
|
if (aDestination.find("x") != std::string::npos)
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
if (aDestination.find("y") != std::string::npos)
|
if (aDestination.find("y") != std::string::npos)
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetWriteChannel(ECHANNEL_Y);
|
if (aDestination.find("z") != std::string::npos)
|
if (aDestination.find("z") != std::string::npos)
|
I.SetWriteChannel(ECHANNEL_Z);
|
I.SetWriteChannel(ECHANNEL_Z);
|
aDestination.erase(aDestination.find("."));
|
aDestination.erase(aDestination.find("."));
|
} else {
|
} else {
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
}
|
}
|
//Now set the destination Index
|
//Now set the destination Index
|
I.SetDestinationAddress( atoi(aDestination.c_str()+1) );
|
I.SetDestinationAddress( atoi(aDestination.c_str()+1) );
|
|
|
|
|
//Now determine the addressing mode
|
//Now determine the addressing mode
|
//Simple addressing modes
|
//Simple addressing modes
|
if (!aHasLiteral && !DetinationHasIndex && !Source0HasIndex && !Source1HasIndex)
|
if (!aHasLiteral && !DetinationHasIndex && !Source0HasIndex && !Source1HasIndex)
|
{
|
{
|
|
|
I.SetAddressingMode( DestinationHasOffset,Source1HasOffset,Source0HasOffset);
|
I.SetAddressingMode( DestinationHasOffset,Source1HasOffset,Source0HasOffset);
|
return;
|
return;
|
}
|
}
|
|
|
|
|
I.SetImmBit( true ); //This is to set the IMM bit = 1, may be overwritten latter
|
I.SetImmBit( true ); //This is to set the IMM bit = 1, may be overwritten latter
|
//Complex addressing modes
|
//Complex addressing modes
|
if
|
if
|
(
|
(
|
aHasLiteral &&
|
aHasLiteral &&
|
!SourceNull( aSource0 ) &&
|
!SourceNull( aSource0 ) &&
|
!Source0HasOffset &&
|
!Source0HasOffset &&
|
!Source1HasOffset &&
|
!Source1HasOffset &&
|
!DestinationHasOffset
|
!DestinationHasOffset
|
)
|
)
|
{
|
{
|
I.SetAddressingMode( false,false,false);
|
I.SetAddressingMode( false,false,false);
|
I.SetImm( aLiteral );
|
I.SetImm( aLiteral );
|
|
|
}
|
}
|
else
|
else
|
if
|
if
|
(
|
(
|
aHasLiteral &&
|
aHasLiteral &&
|
!SourceNull( aSource0 ) &&
|
!SourceNull( aSource0 ) &&
|
Source0HasOffset &&
|
Source0HasOffset &&
|
!Source0HasIndex &&
|
!Source0HasIndex &&
|
DestinationHasOffset
|
DestinationHasOffset
|
|
|
)
|
)
|
{
|
{
|
|
|
I.SetAddressingMode( false,false,true);
|
I.SetAddressingMode( false,false,true);
|
I.SetImm( aLiteral );
|
I.SetImm( aLiteral );
|
|
|
|
|
}
|
}
|
else
|
else
|
if
|
if
|
(
|
(
|
!aHasLiteral &&
|
!aHasLiteral &&
|
!SourceNull( aSource1 ) &&
|
!SourceNull( aSource1 ) &&
|
!Source1HasOffset &&
|
!Source1HasOffset &&
|
!SourceNull( aSource0 ) &&
|
!SourceNull( aSource0 ) &&
|
Source0HasOffset &&
|
Source0HasOffset &&
|
Source0HasIndex &&
|
Source0HasIndex &&
|
DestinationHasOffset
|
DestinationHasOffset
|
|
|
)
|
)
|
{
|
{
|
I.SetAddressingMode( false,true,false);
|
I.SetAddressingMode( false,true,false);
|
|
|
}
|
}
|
else
|
else
|
if
|
if
|
(
|
(
|
!aHasLiteral &&
|
!aHasLiteral &&
|
!Source1HasOffset &&
|
!Source1HasOffset &&
|
!SourceNull( aSource0 ) &&
|
!SourceNull( aSource0 ) &&
|
Source0HasOffset &&
|
Source0HasOffset &&
|
!Source0HasIndex &&
|
!Source0HasIndex &&
|
DestinationHasOffset &&
|
DestinationHasOffset &&
|
DetinationHasIndex
|
DetinationHasIndex
|
|
|
)
|
)
|
{
|
{
|
I.SetAddressingMode( false,true,true);
|
I.SetAddressingMode( false,true,true);
|
|
|
}
|
}
|
else
|
else
|
if
|
if
|
(
|
(
|
aHasLiteral &&
|
aHasLiteral &&
|
SourceNull( aSource0 ) &&
|
SourceNull( aSource0 ) &&
|
!DestinationHasOffset &&
|
!DestinationHasOffset &&
|
!DetinationHasIndex
|
!DetinationHasIndex
|
|
|
)
|
)
|
{
|
{
|
|
|
|
|
I.SetAddressingMode( true,false,false);
|
I.SetAddressingMode( true,false,false);
|
I.SetImm( aLiteral );
|
I.SetImm( aLiteral );
|
}
|
}
|
else
|
else
|
if
|
if
|
(
|
(
|
aHasLiteral &&
|
aHasLiteral &&
|
SourceNull( aSource0 ) &&
|
SourceNull( aSource0 ) &&
|
DestinationHasOffset &&
|
DestinationHasOffset &&
|
!DetinationHasIndex
|
!DetinationHasIndex
|
|
|
)
|
)
|
{
|
{
|
|
|
I.SetAddressingMode( true,false,true);
|
I.SetAddressingMode( true,false,true);
|
I.SetImm( aLiteral );
|
I.SetImm( aLiteral );
|
}
|
}
|
else
|
else
|
if
|
if
|
(
|
(
|
!aHasLiteral &&
|
!aHasLiteral &&
|
Source1HasOffset &&
|
Source1HasOffset &&
|
Source1HasIndex &&
|
Source1HasIndex &&
|
SourceNull( aSource0 ) &&
|
SourceNull( aSource0 ) &&
|
DestinationHasOffset &&
|
DestinationHasOffset &&
|
!DetinationHasIndex
|
!DetinationHasIndex
|
|
|
)
|
)
|
{
|
{
|
|
|
I.SetAddressingMode( true,true,false);
|
I.SetAddressingMode( true,true,false);
|
}
|
}
|
else
|
else
|
if
|
if
|
(
|
(
|
!aHasLiteral &&
|
!aHasLiteral &&
|
Source1HasOffset &&
|
Source1HasOffset &&
|
Source1HasIndex &&
|
Source1HasIndex &&
|
Source0HasOffset &&
|
Source0HasOffset &&
|
!Source0HasIndex &&
|
!Source0HasIndex &&
|
DestinationHasOffset &&
|
DestinationHasOffset &&
|
!DetinationHasIndex
|
!DetinationHasIndex
|
|
|
)
|
)
|
{
|
{
|
|
|
I.SetAddressingMode( true,true,true);
|
I.SetAddressingMode( true,true,true);
|
} else {
|
} else {
|
std::ostringstream ret;
|
std::ostringstream ret;
|
ret << "Could not determine addressing mode at line " << yylloc << " \n";
|
ret << "Could not determine addressing mode at line " << yylloc << " \n";
|
throw ret.str();
|
throw ret.str();
|
}
|
}
|
|
|
|
|
}
|
}
|
|
|
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
void PopulateBoolean(EBRANCHTYPE aBranchType, std::string Source1, std::string Source0, Instruction & I, std::vector<Instruction> & aInstructions, Theia::Parser::location_type & yylloc )
|
void PopulateBoolean(EBRANCHTYPE aBranchType, std::string Source1, std::string Source0, Instruction & I, std::vector<Instruction> & aInstructions, Theia::Parser::location_type & yylloc )
|
{
|
{
|
|
|
if (Source0.find("R") == std::string::npos)
|
if (Source0.find("R") == std::string::npos)
|
{
|
{
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestinationAddress( TempRegIndex );
|
unsigned int ImmediateValue;
|
unsigned int ImmediateValue;
|
std::string StringHex = Source0;
|
std::string StringHex = Source0;
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
I.SetImm( ImmediateValue );
|
I.SetImm( ImmediateValue );
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.SetSrc0Displace( true );
|
I.SetSrc0Displace( true );
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetWriteChannel(ECHANNEL_Z);
|
I.SetWriteChannel(ECHANNEL_Z);
|
aInstructions.push_back(I);
|
aInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
|
|
std::stringstream ss2;
|
std::stringstream ss2;
|
ss2 << "R" << TempRegIndex;
|
ss2 << "R" << TempRegIndex;
|
ss2 >> Source0;
|
ss2 >> Source0;
|
Source0 += " OFFSET ";
|
Source0 += " OFFSET ";
|
|
|
}
|
}
|
else
|
else
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
|
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.SetSrc0SignX( true );
|
I.SetSrc0SignX( true );
|
I.SetSrc0SignY( true );
|
I.SetSrc0SignY( true );
|
I.SetSrc0SignZ( true );
|
I.SetSrc0SignZ( true );
|
I.SetBranchFlag( true );
|
I.SetBranchFlag( true );
|
I.ClearWriteChannel();
|
I.ClearWriteChannel();
|
I.SetBranchType( aBranchType );
|
I.SetBranchType( aBranchType );
|
|
|
PopulateSourceRegisters( Source1, Source0, I, aInstructions);
|
PopulateSourceRegisters( Source1, Source0, I, aInstructions);
|
aInstructions.push_back(I);
|
aInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
////std::cout << "pushing code at position " << (mInstructions.size() - 1) << "\n";
|
////std::cout << "pushing code at position " << (mInstructions.size() - 1) << "\n";
|
gBranchStack.push_back(aInstructions.size() - 1);
|
gBranchStack.push_back(aInstructions.size() - 1);
|
ResetTempRegisterIndex();
|
ResetTempRegisterIndex();
|
}
|
}
|
|
|
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
// Prototype for the yylex function
|
// Prototype for the yylex function
|
static int yylex(Theia::Parser::semantic_type * yylval,
|
static int yylex(Theia::Parser::semantic_type * yylval,
|
Theia::Parser::location_type * yylloc,
|
Theia::Parser::location_type * yylloc,
|
Theia::Scanner &scanner);
|
Theia::Scanner &scanner);
|
|
|
|
|
|
|
/* Line 318 of lalr1.cc */
|
/* Line 318 of lalr1.cc */
|
#line 815 "parser.tab.c"
|
#line 824 "parser.tab.c"
|
|
|
#ifndef YY_
|
#ifndef YY_
|
# if YYENABLE_NLS
|
# if YYENABLE_NLS
|
# if ENABLE_NLS
|
# if ENABLE_NLS
|
# include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
|
# include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
|
# define YY_(msgid) dgettext ("bison-runtime", msgid)
|
# define YY_(msgid) dgettext ("bison-runtime", msgid)
|
# endif
|
# endif
|
# endif
|
# endif
|
# ifndef YY_
|
# ifndef YY_
|
# define YY_(msgid) msgid
|
# define YY_(msgid) msgid
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
/* Suppress unused-variable warnings by "using" E. */
|
/* Suppress unused-variable warnings by "using" E. */
|
#define YYUSE(e) ((void) (e))
|
#define YYUSE(e) ((void) (e))
|
|
|
/* Enable debugging if requested. */
|
/* Enable debugging if requested. */
|
#if YYDEBUG
|
#if YYDEBUG
|
|
|
/* A pseudo ostream that takes yydebug_ into account. */
|
/* A pseudo ostream that takes yydebug_ into account. */
|
# define YYCDEBUG if (yydebug_) (*yycdebug_)
|
# define YYCDEBUG if (yydebug_) (*yycdebug_)
|
|
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
do { \
|
do { \
|
if (yydebug_) \
|
if (yydebug_) \
|
{ \
|
{ \
|
*yycdebug_ << Title << ' '; \
|
*yycdebug_ << Title << ' '; \
|
yy_symbol_print_ ((Type), (Value), (Location)); \
|
yy_symbol_print_ ((Type), (Value), (Location)); \
|
*yycdebug_ << std::endl; \
|
*yycdebug_ << std::endl; \
|
} \
|
} \
|
} while (false)
|
} while (false)
|
|
|
# define YY_REDUCE_PRINT(Rule) \
|
# define YY_REDUCE_PRINT(Rule) \
|
do { \
|
do { \
|
if (yydebug_) \
|
if (yydebug_) \
|
yy_reduce_print_ (Rule); \
|
yy_reduce_print_ (Rule); \
|
} while (false)
|
} while (false)
|
|
|
# define YY_STACK_PRINT() \
|
# define YY_STACK_PRINT() \
|
do { \
|
do { \
|
if (yydebug_) \
|
if (yydebug_) \
|
yystack_print_ (); \
|
yystack_print_ (); \
|
} while (false)
|
} while (false)
|
|
|
#else /* !YYDEBUG */
|
#else /* !YYDEBUG */
|
|
|
# define YYCDEBUG if (false) std::cerr
|
# define YYCDEBUG if (false) std::cerr
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
# define YY_REDUCE_PRINT(Rule)
|
# define YY_REDUCE_PRINT(Rule)
|
# define YY_STACK_PRINT()
|
# define YY_STACK_PRINT()
|
|
|
#endif /* !YYDEBUG */
|
#endif /* !YYDEBUG */
|
|
|
#define yyerrok (yyerrstatus_ = 0)
|
#define yyerrok (yyerrstatus_ = 0)
|
#define yyclearin (yychar = yyempty_)
|
#define yyclearin (yychar = yyempty_)
|
|
|
#define YYACCEPT goto yyacceptlab
|
#define YYACCEPT goto yyacceptlab
|
#define YYABORT goto yyabortlab
|
#define YYABORT goto yyabortlab
|
#define YYERROR goto yyerrorlab
|
#define YYERROR goto yyerrorlab
|
#define YYRECOVERING() (!!yyerrstatus_)
|
#define YYRECOVERING() (!!yyerrstatus_)
|
|
|
|
|
/* Line 380 of lalr1.cc */
|
/* Line 380 of lalr1.cc */
|
#line 28 "parser.y"
|
#line 28 "parser.y"
|
namespace Theia {
|
namespace Theia {
|
|
|
/* Line 380 of lalr1.cc */
|
/* Line 380 of lalr1.cc */
|
#line 883 "parser.tab.c"
|
#line 892 "parser.tab.c"
|
#if YYERROR_VERBOSE
|
#if YYERROR_VERBOSE
|
|
|
/* Return YYSTR after stripping away unnecessary quotes and
|
/* Return YYSTR after stripping away unnecessary quotes and
|
backslashes, so that it's suitable for yyerror. The heuristic is
|
backslashes, so that it's suitable for yyerror. The heuristic is
|
that double-quoting is unnecessary unless the string contains an
|
that double-quoting is unnecessary unless the string contains an
|
apostrophe, a comma, or backslash (other than backslash-backslash).
|
apostrophe, a comma, or backslash (other than backslash-backslash).
|
YYSTR is taken from yytname. */
|
YYSTR is taken from yytname. */
|
std::string
|
std::string
|
Parser::yytnamerr_ (const char *yystr)
|
Parser::yytnamerr_ (const char *yystr)
|
{
|
{
|
if (*yystr == '"')
|
if (*yystr == '"')
|
{
|
{
|
std::string yyr = "";
|
std::string yyr = "";
|
char const *yyp = yystr;
|
char const *yyp = yystr;
|
|
|
for (;;)
|
for (;;)
|
switch (*++yyp)
|
switch (*++yyp)
|
{
|
{
|
case '\'':
|
case '\'':
|
case ',':
|
case ',':
|
goto do_not_strip_quotes;
|
goto do_not_strip_quotes;
|
|
|
case '\\':
|
case '\\':
|
if (*++yyp != '\\')
|
if (*++yyp != '\\')
|
goto do_not_strip_quotes;
|
goto do_not_strip_quotes;
|
/* Fall through. */
|
/* Fall through. */
|
default:
|
default:
|
yyr += *yyp;
|
yyr += *yyp;
|
break;
|
break;
|
|
|
case '"':
|
case '"':
|
return yyr;
|
return yyr;
|
}
|
}
|
do_not_strip_quotes: ;
|
do_not_strip_quotes: ;
|
}
|
}
|
|
|
return yystr;
|
return yystr;
|
}
|
}
|
|
|
#endif
|
#endif
|
|
|
/// Build a parser object.
|
/// Build a parser object.
|
Parser::Parser (Theia::Scanner &scanner_yyarg, std::map<std::string,unsigned int> & mSymbolMap_yyarg, std::vector< Instruction > &mInstructions_yyarg, bool &mGenerateFixedPointArithmetic_yyarg)
|
Parser::Parser (Theia::Scanner &scanner_yyarg, std::map<std::string,unsigned int> & mSymbolMap_yyarg, std::vector< Instruction > &mInstructions_yyarg, bool &mGenerateFixedPointArithmetic_yyarg)
|
:
|
:
|
#if YYDEBUG
|
#if YYDEBUG
|
yydebug_ (false),
|
yydebug_ (false),
|
yycdebug_ (&std::cerr),
|
yycdebug_ (&std::cerr),
|
#endif
|
#endif
|
scanner (scanner_yyarg),
|
scanner (scanner_yyarg),
|
mSymbolMap (mSymbolMap_yyarg),
|
mSymbolMap (mSymbolMap_yyarg),
|
mInstructions (mInstructions_yyarg),
|
mInstructions (mInstructions_yyarg),
|
mGenerateFixedPointArithmetic (mGenerateFixedPointArithmetic_yyarg)
|
mGenerateFixedPointArithmetic (mGenerateFixedPointArithmetic_yyarg)
|
{
|
{
|
}
|
}
|
|
|
Parser::~Parser ()
|
Parser::~Parser ()
|
{
|
{
|
}
|
}
|
|
|
#if YYDEBUG
|
#if YYDEBUG
|
/*--------------------------------.
|
/*--------------------------------.
|
| Print this symbol on YYOUTPUT. |
|
| Print this symbol on YYOUTPUT. |
|
`--------------------------------*/
|
`--------------------------------*/
|
|
|
inline void
|
inline void
|
Parser::yy_symbol_value_print_ (int yytype,
|
Parser::yy_symbol_value_print_ (int yytype,
|
const semantic_type* yyvaluep, const location_type* yylocationp)
|
const semantic_type* yyvaluep, const location_type* yylocationp)
|
{
|
{
|
YYUSE (yylocationp);
|
YYUSE (yylocationp);
|
YYUSE (yyvaluep);
|
YYUSE (yyvaluep);
|
switch (yytype)
|
switch (yytype)
|
{
|
{
|
default:
|
default:
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
|
|
void
|
void
|
Parser::yy_symbol_print_ (int yytype,
|
Parser::yy_symbol_print_ (int yytype,
|
const semantic_type* yyvaluep, const location_type* yylocationp)
|
const semantic_type* yyvaluep, const location_type* yylocationp)
|
{
|
{
|
*yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
|
*yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
|
<< ' ' << yytname_[yytype] << " ("
|
<< ' ' << yytname_[yytype] << " ("
|
<< *yylocationp << ": ";
|
<< *yylocationp << ": ";
|
yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
|
yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
|
*yycdebug_ << ')';
|
*yycdebug_ << ')';
|
}
|
}
|
#endif
|
#endif
|
|
|
void
|
void
|
Parser::yydestruct_ (const char* yymsg,
|
Parser::yydestruct_ (const char* yymsg,
|
int yytype, semantic_type* yyvaluep, location_type* yylocationp)
|
int yytype, semantic_type* yyvaluep, location_type* yylocationp)
|
{
|
{
|
YYUSE (yylocationp);
|
YYUSE (yylocationp);
|
YYUSE (yymsg);
|
YYUSE (yymsg);
|
YYUSE (yyvaluep);
|
YYUSE (yyvaluep);
|
|
|
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
|
|
switch (yytype)
|
switch (yytype)
|
{
|
{
|
|
|
default:
|
default:
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
void
|
void
|
Parser::yypop_ (unsigned int n)
|
Parser::yypop_ (unsigned int n)
|
{
|
{
|
yystate_stack_.pop (n);
|
yystate_stack_.pop (n);
|
yysemantic_stack_.pop (n);
|
yysemantic_stack_.pop (n);
|
yylocation_stack_.pop (n);
|
yylocation_stack_.pop (n);
|
}
|
}
|
|
|
#if YYDEBUG
|
#if YYDEBUG
|
std::ostream&
|
std::ostream&
|
Parser::debug_stream () const
|
Parser::debug_stream () const
|
{
|
{
|
return *yycdebug_;
|
return *yycdebug_;
|
}
|
}
|
|
|
void
|
void
|
Parser::set_debug_stream (std::ostream& o)
|
Parser::set_debug_stream (std::ostream& o)
|
{
|
{
|
yycdebug_ = &o;
|
yycdebug_ = &o;
|
}
|
}
|
|
|
|
|
Parser::debug_level_type
|
Parser::debug_level_type
|
Parser::debug_level () const
|
Parser::debug_level () const
|
{
|
{
|
return yydebug_;
|
return yydebug_;
|
}
|
}
|
|
|
void
|
void
|
Parser::set_debug_level (debug_level_type l)
|
Parser::set_debug_level (debug_level_type l)
|
{
|
{
|
yydebug_ = l;
|
yydebug_ = l;
|
}
|
}
|
#endif
|
#endif
|
|
|
int
|
int
|
Parser::parse ()
|
Parser::parse ()
|
{
|
{
|
/// Lookahead and lookahead in internal form.
|
/// Lookahead and lookahead in internal form.
|
int yychar = yyempty_;
|
int yychar = yyempty_;
|
int yytoken = 0;
|
int yytoken = 0;
|
|
|
/* State. */
|
/* State. */
|
int yyn;
|
int yyn;
|
int yylen = 0;
|
int yylen = 0;
|
int yystate = 0;
|
int yystate = 0;
|
|
|
/* Error handling. */
|
/* Error handling. */
|
int yynerrs_ = 0;
|
int yynerrs_ = 0;
|
int yyerrstatus_ = 0;
|
int yyerrstatus_ = 0;
|
|
|
/// Semantic value of the lookahead.
|
/// Semantic value of the lookahead.
|
semantic_type yylval;
|
semantic_type yylval;
|
/// Location of the lookahead.
|
/// Location of the lookahead.
|
location_type yylloc;
|
location_type yylloc;
|
/// The locations where the error started and ended.
|
/// The locations where the error started and ended.
|
location_type yyerror_range[2];
|
location_type yyerror_range[2];
|
|
|
/// $$.
|
/// $$.
|
semantic_type yyval;
|
semantic_type yyval;
|
/// @$.
|
/// @$.
|
location_type yyloc;
|
location_type yyloc;
|
|
|
int yyresult;
|
int yyresult;
|
|
|
YYCDEBUG << "Starting parse" << std::endl;
|
YYCDEBUG << "Starting parse" << std::endl;
|
|
|
|
|
/* Initialize the stacks. The initial state will be pushed in
|
/* Initialize the stacks. The initial state will be pushed in
|
yynewstate, since the latter expects the semantical and the
|
yynewstate, since the latter expects the semantical and the
|
location values to have been already stored, initialize these
|
location values to have been already stored, initialize these
|
stacks with a primary value. */
|
stacks with a primary value. */
|
yystate_stack_ = state_stack_type (0);
|
yystate_stack_ = state_stack_type (0);
|
yysemantic_stack_ = semantic_stack_type (0);
|
yysemantic_stack_ = semantic_stack_type (0);
|
yylocation_stack_ = location_stack_type (0);
|
yylocation_stack_ = location_stack_type (0);
|
yysemantic_stack_.push (yylval);
|
yysemantic_stack_.push (yylval);
|
yylocation_stack_.push (yylloc);
|
yylocation_stack_.push (yylloc);
|
|
|
/* New state. */
|
/* New state. */
|
yynewstate:
|
yynewstate:
|
yystate_stack_.push (yystate);
|
yystate_stack_.push (yystate);
|
YYCDEBUG << "Entering state " << yystate << std::endl;
|
YYCDEBUG << "Entering state " << yystate << std::endl;
|
|
|
/* Accept? */
|
/* Accept? */
|
if (yystate == yyfinal_)
|
if (yystate == yyfinal_)
|
goto yyacceptlab;
|
goto yyacceptlab;
|
|
|
goto yybackup;
|
goto yybackup;
|
|
|
/* Backup. */
|
/* Backup. */
|
yybackup:
|
yybackup:
|
|
|
/* Try to take a decision without lookahead. */
|
/* Try to take a decision without lookahead. */
|
yyn = yypact_[yystate];
|
yyn = yypact_[yystate];
|
if (yyn == yypact_ninf_)
|
if (yyn == yypact_ninf_)
|
goto yydefault;
|
goto yydefault;
|
|
|
/* Read a lookahead token. */
|
/* Read a lookahead token. */
|
if (yychar == yyempty_)
|
if (yychar == yyempty_)
|
{
|
{
|
YYCDEBUG << "Reading a token: ";
|
YYCDEBUG << "Reading a token: ";
|
yychar = yylex (&yylval, &yylloc, scanner);
|
yychar = yylex (&yylval, &yylloc, scanner);
|
}
|
}
|
|
|
|
|
/* Convert token to internal form. */
|
/* Convert token to internal form. */
|
if (yychar <= yyeof_)
|
if (yychar <= yyeof_)
|
{
|
{
|
yychar = yytoken = yyeof_;
|
yychar = yytoken = yyeof_;
|
YYCDEBUG << "Now at end of input." << std::endl;
|
YYCDEBUG << "Now at end of input." << std::endl;
|
}
|
}
|
else
|
else
|
{
|
{
|
yytoken = yytranslate_ (yychar);
|
yytoken = yytranslate_ (yychar);
|
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
|
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
|
}
|
}
|
|
|
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
detect an error, take that action. */
|
detect an error, take that action. */
|
yyn += yytoken;
|
yyn += yytoken;
|
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
|
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
|
goto yydefault;
|
goto yydefault;
|
|
|
/* Reduce or error. */
|
/* Reduce or error. */
|
yyn = yytable_[yyn];
|
yyn = yytable_[yyn];
|
if (yyn <= 0)
|
if (yyn <= 0)
|
{
|
{
|
if (yyn == 0 || yyn == yytable_ninf_)
|
if (yyn == 0 || yyn == yytable_ninf_)
|
goto yyerrlab;
|
goto yyerrlab;
|
yyn = -yyn;
|
yyn = -yyn;
|
goto yyreduce;
|
goto yyreduce;
|
}
|
}
|
|
|
/* Shift the lookahead token. */
|
/* Shift the lookahead token. */
|
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
|
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
|
|
|
/* Discard the token being shifted. */
|
/* Discard the token being shifted. */
|
yychar = yyempty_;
|
yychar = yyempty_;
|
|
|
yysemantic_stack_.push (yylval);
|
yysemantic_stack_.push (yylval);
|
yylocation_stack_.push (yylloc);
|
yylocation_stack_.push (yylloc);
|
|
|
/* Count tokens shifted since error; after three, turn off error
|
/* Count tokens shifted since error; after three, turn off error
|
status. */
|
status. */
|
if (yyerrstatus_)
|
if (yyerrstatus_)
|
--yyerrstatus_;
|
--yyerrstatus_;
|
|
|
yystate = yyn;
|
yystate = yyn;
|
goto yynewstate;
|
goto yynewstate;
|
|
|
/*-----------------------------------------------------------.
|
/*-----------------------------------------------------------.
|
| yydefault -- do the default action for the current state. |
|
| yydefault -- do the default action for the current state. |
|
`-----------------------------------------------------------*/
|
`-----------------------------------------------------------*/
|
yydefault:
|
yydefault:
|
yyn = yydefact_[yystate];
|
yyn = yydefact_[yystate];
|
if (yyn == 0)
|
if (yyn == 0)
|
goto yyerrlab;
|
goto yyerrlab;
|
goto yyreduce;
|
goto yyreduce;
|
|
|
/*-----------------------------.
|
/*-----------------------------.
|
| yyreduce -- Do a reduction. |
|
| yyreduce -- Do a reduction. |
|
`-----------------------------*/
|
`-----------------------------*/
|
yyreduce:
|
yyreduce:
|
yylen = yyr2_[yyn];
|
yylen = yyr2_[yyn];
|
/* If YYLEN is nonzero, implement the default value of the action:
|
/* If YYLEN is nonzero, implement the default value of the action:
|
`$$ = $1'. Otherwise, use the top of the stack.
|
`$$ = $1'. Otherwise, use the top of the stack.
|
|
|
Otherwise, the following line sets YYVAL to garbage.
|
Otherwise, the following line sets YYVAL to garbage.
|
This behavior is undocumented and Bison
|
This behavior is undocumented and Bison
|
users should not rely upon it. */
|
users should not rely upon it. */
|
if (yylen)
|
if (yylen)
|
yyval = yysemantic_stack_[yylen - 1];
|
yyval = yysemantic_stack_[yylen - 1];
|
else
|
else
|
yyval = yysemantic_stack_[0];
|
yyval = yysemantic_stack_[0];
|
|
|
{
|
{
|
slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);
|
slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);
|
YYLLOC_DEFAULT (yyloc, slice, yylen);
|
YYLLOC_DEFAULT (yyloc, slice, yylen);
|
}
|
}
|
YY_REDUCE_PRINT (yyn);
|
YY_REDUCE_PRINT (yyn);
|
switch (yyn)
|
switch (yyn)
|
{
|
{
|
case 6:
|
case 6:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 842 "parser.y"
|
#line 851 "parser.y"
|
{
|
{
|
mGenerateFixedPointArithmetic = true;
|
mGenerateFixedPointArithmetic = true;
|
}
|
}
|
break;
|
break;
|
|
|
case 7:
|
case 7:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 847 "parser.y"
|
#line 856 "parser.y"
|
{
|
{
|
//Insert a stupid NOP before the exit... is a bug but easier to just patch like this...
|
//Insert a stupid NOP before the exit... is a bug but easier to just patch like this...
|
|
|
I.Clear();
|
I.Clear();
|
I.mComment = "NOP";
|
I.mComment = "NOP";
|
I.SetCode( EOPERATION_NOP );
|
I.SetCode( EOPERATION_NOP );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
|
|
I.SetEofFlag(true);
|
I.SetEofFlag(true);
|
I.mComment = "Set the Exit bit";
|
I.mComment = "Set the Exit bit";
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
}
|
}
|
break;
|
break;
|
|
|
case 8:
|
case 8:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 864 "parser.y"
|
#line 873 "parser.y"
|
{
|
{
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
// This means this that the expression was just a constant.
|
// This means this that the expression was just a constant.
|
// No operations were inserted
|
// No operations were inserted
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
if (gInsertedInstructions == 0)
|
if (gInsertedInstructions == 0)
|
{
|
{
|
I.Clear();
|
I.Clear();
|
I.SetCode(EOPERATION_ADD);
|
I.SetCode(EOPERATION_ADD);
|
I.mComment ="Set the return value";
|
I.mComment ="Set the return value";
|
if ((yysemantic_stack_[(3) - (3)]).find("R") != std::string::npos)
|
if ((yysemantic_stack_[(3) - (3)]).find("R") != std::string::npos)
|
{
|
{
|
PopulateInstruction( "R1", (yysemantic_stack_[(3) - (2)]),"R0 . X X X",I,yylloc);
|
PopulateInstruction( "R1", (yysemantic_stack_[(3) - (2)]),"R0 . X X X",I,yylloc);
|
}
|
}
|
else
|
else
|
{
|
{
|
unsigned int ImmediateValue = 0;
|
unsigned int ImmediateValue = 0;
|
std::string StringHex = (yysemantic_stack_[(3) - (3)]);
|
std::string StringHex = (yysemantic_stack_[(3) - (3)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
PopulateInstruction( "R1", (yysemantic_stack_[(3) - (3)]),"NULL",I, yylloc, true, ImmediateValue);
|
PopulateInstruction( "R1", (yysemantic_stack_[(3) - (3)]),"NULL",I, yylloc, true, ImmediateValue);
|
}
|
}
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
} else {
|
} else {
|
|
|
mInstructions[ mInstructions.size() - gInsertedInstructions].mSourceLine = GetCurrentLineNumber(yylloc);
|
mInstructions[ mInstructions.size() - gInsertedInstructions].mSourceLine = GetCurrentLineNumber(yylloc);
|
gInsertedInstructions = 0;
|
gInsertedInstructions = 0;
|
mInstructions.back().mComment ="Assigning return value";
|
mInstructions.back().mComment ="Assigning return value";
|
mInstructions.back().SetDestinationAddress( RETURN_VALUE_REGISTER );
|
mInstructions.back().SetDestinationAddress( RETURN_VALUE_REGISTER );
|
|
|
}
|
}
|
ResetTempRegisterIndex();
|
ResetTempRegisterIndex();
|
|
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "Restore previous function frame offset";
|
I.mComment = "Restore previous function frame offset";
|
I.ClearWriteChannel();
|
I.ClearWriteChannel();
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetSrc1Address(SPR_CONTROL_REGISTER);
|
I.SetSrc1Address(SPR_CONTROL_REGISTER);
|
I.SetSrc1SwizzleX(SWX_Y);
|
I.SetSrc1SwizzleX(SWX_Y);
|
I.SetSrc1SwizzleY(SWY_Y);
|
I.SetSrc1SwizzleY(SWY_Y);
|
I.SetSrc1SwizzleZ(SWZ_Y);
|
I.SetSrc1SwizzleZ(SWZ_Y);
|
I.SetSrc0Address(0);
|
I.SetSrc0Address(0);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
|
|
//Now return
|
//Now return
|
I.SetImm( 0 );
|
I.SetImm( 0 );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "return from function";
|
I.mComment = "return from function";
|
I.SetBranchFlag( true );
|
I.SetBranchFlag( true );
|
I.SetBranchType( EBRANCH_ALWAYS );
|
I.SetBranchType( EBRANCH_ALWAYS );
|
I.SetDestinationAddress( RETURN_ADDRESS_REGISTER );
|
I.SetDestinationAddress( RETURN_ADDRESS_REGISTER );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
|
|
|
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 9:
|
case 9:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 931 "parser.y"
|
#line 940 "parser.y"
|
{
|
{
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "Restore previous function frame offset";
|
I.mComment = "Restore previous function frame offset";
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetSrc1Address(SPR_CONTROL_REGISTER);
|
I.SetSrc1Address(SPR_CONTROL_REGISTER);
|
I.SetSrc1SwizzleX(SWX_Y);
|
I.SetSrc1SwizzleX(SWX_Y);
|
I.SetSrc1SwizzleY(SWY_Y);
|
I.SetSrc1SwizzleY(SWY_Y);
|
I.SetSrc1SwizzleZ(SWZ_Y);
|
I.SetSrc1SwizzleZ(SWZ_Y);
|
I.SetSrc0Address(0);
|
I.SetSrc0Address(0);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
|
|
I.SetImm( 0 );
|
I.SetImm( 0 );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "return from function";
|
I.mComment = "return from function";
|
I.SetBranchFlag( true );
|
I.SetBranchFlag( true );
|
I.SetBranchType( EBRANCH_ALWAYS );
|
I.SetBranchType( EBRANCH_ALWAYS );
|
I.SetDestinationAddress( RETURN_ADDRESS_REGISTER );
|
I.SetDestinationAddress( RETURN_ADDRESS_REGISTER );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
}
|
}
|
break;
|
break;
|
|
|
case 10:
|
case 10:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 959 "parser.y"
|
#line 968 "parser.y"
|
{
|
{
|
|
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
SetDestinationFromRegister( (yysemantic_stack_[(4) - (1)]), I , true);
|
SetDestinationFromRegister( (yysemantic_stack_[(4) - (1)]), I , true);
|
unsigned int ImmediateValue;
|
unsigned int ImmediateValue;
|
std::string StringHex = (yysemantic_stack_[(4) - (3)]);
|
std::string StringHex = (yysemantic_stack_[(4) - (3)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
I.SetImm( ImmediateValue );
|
I.SetImm( ImmediateValue );
|
I.SetDestZero( false );
|
I.SetDestZero( false );
|
|
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
}
|
}
|
break;
|
break;
|
|
|
case 11:
|
case 11:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 977 "parser.y"
|
#line 986 "parser.y"
|
{
|
{
|
|
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
SetDestinationFromRegister( (yysemantic_stack_[(4) - (1)]), I, false );
|
SetDestinationFromRegister( (yysemantic_stack_[(4) - (1)]), I, false );
|
I.SetSrc0SignX( true );
|
I.SetSrc0SignX( true );
|
I.SetSrc0SignY( true );
|
I.SetSrc0SignY( true );
|
I.SetSrc0SignZ( true );
|
I.SetSrc0SignZ( true );
|
std::string Destination = (yysemantic_stack_[(4) - (1)]);
|
std::string Destination = (yysemantic_stack_[(4) - (1)]);
|
if (Destination.find("OFFSET") != std::string::npos)
|
if (Destination.find("OFFSET") != std::string::npos)
|
{
|
{
|
I.SetSrc1Displace( true );
|
I.SetSrc1Displace( true );
|
Destination.erase(Destination.find("OFFSET"));
|
Destination.erase(Destination.find("OFFSET"));
|
}
|
}
|
|
|
if (Destination.find(".") != std::string::npos)
|
if (Destination.find(".") != std::string::npos)
|
Destination.erase(Destination.find("."));
|
Destination.erase(Destination.find("."));
|
|
|
|
|
I.SetSrc1Address(atoi(Destination.c_str()+1));
|
I.SetSrc1Address(atoi(Destination.c_str()+1));
|
I.SetSrc0Address(0);
|
I.SetSrc0Address(0);
|
I.SetSrc0SwizzleX(SWX_Y);
|
I.SetSrc0SwizzleX(SWX_Y);
|
I.SetSrc0SwizzleY(SWY_Y);
|
I.SetSrc0SwizzleY(SWY_Y);
|
I.SetSrc0SwizzleZ(SWZ_Y);
|
I.SetSrc0SwizzleZ(SWZ_Y);
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
}
|
}
|
break;
|
break;
|
|
|
case 12:
|
case 12:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1006 "parser.y"
|
#line 1015 "parser.y"
|
{
|
{
|
|
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
SetDestinationFromRegister( (yysemantic_stack_[(4) - (1)]), I, false );
|
SetDestinationFromRegister( (yysemantic_stack_[(4) - (1)]), I, false );
|
std::string Destination = (yysemantic_stack_[(4) - (1)]);
|
std::string Destination = (yysemantic_stack_[(4) - (1)]);
|
if (Destination.find("OFFSET") != std::string::npos)
|
if (Destination.find("OFFSET") != std::string::npos)
|
{
|
{
|
I.SetSrc1Displace( true );
|
I.SetSrc1Displace( true );
|
Destination.erase(Destination.find("OFFSET"));
|
Destination.erase(Destination.find("OFFSET"));
|
}
|
}
|
|
|
if (Destination.find(".") != std::string::npos)
|
if (Destination.find(".") != std::string::npos)
|
Destination.erase(Destination.find("."));
|
Destination.erase(Destination.find("."));
|
|
|
I.SetSrc1Address(atoi(Destination.c_str()+1));
|
I.SetSrc1Address(atoi(Destination.c_str()+1));
|
I.SetSrc0Address(0);
|
I.SetSrc0Address(0);
|
I.SetSrc0SwizzleX(SWX_Y);
|
I.SetSrc0SwizzleX(SWX_Y);
|
I.SetSrc0SwizzleY(SWY_Y);
|
I.SetSrc0SwizzleY(SWY_Y);
|
I.SetSrc0SwizzleZ(SWZ_Y);
|
I.SetSrc0SwizzleZ(SWZ_Y);
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
}
|
}
|
break;
|
break;
|
|
|
case 13:
|
case 13:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1031 "parser.y"
|
#line 1040 "parser.y"
|
{
|
{
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
|
// This means this that the expression will read from the T memory
|
|
// variable index
|
|
// For example:
|
|
// vector MyAddress,MyReadValue;
|
|
// MyReadValue = in [ MyAddress ];
|
|
//
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
DCOUT << (yysemantic_stack_[(4) - (3)]) << " YYY \n";
|
|
if ((yysemantic_stack_[(4) - (3)]).find("IN") != std::string::npos )
|
|
{
|
|
|
|
std::string ReadAddress = (yysemantic_stack_[(4) - (3)]);
|
|
|
|
std::string SourceAddrRegister = ReadAddress.substr(ReadAddress.find("INDEX")+5);
|
|
DCOUT << "!!!!!!!!!!!!!!!!! " << ReadAddress << "\n";
|
|
ReadAddress.erase(0,ReadAddress.find("IN")+3);
|
|
DCOUT << "!!!!!!!!!!!!!!!!! " << ReadAddress << "\n";
|
|
|
|
I.SetDestZero( true ); //Use indexing for DST
|
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
|
|
|
|
|
PopulateSourceRegisters( ReadAddress, "R0", I, mInstructions );
|
|
|
|
SetDestinationFromRegister( (yysemantic_stack_[(4) - (1)]), I, false );
|
|
I.mSourceLine = GetCurrentLineNumber(yylloc);
|
|
I.SetCode( EOPERATION_IO );
|
|
I.SetIOOperation( EIO_TMREAD );
|
|
|
|
|
|
mInstructions.push_back( I );
|
|
I.Clear();
|
|
ResetTempRegisterIndex();
|
|
goto LABEL_EXPRESSION_DONE;
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////////
|
// This means this that the expression will write into the output memory
|
// This means this that the expression will write into the output memory
|
// constant index
|
// constant index
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
if ((yysemantic_stack_[(4) - (1)]).find("OUT") != std::string::npos && (yysemantic_stack_[(4) - (1)]).find("INDEX") == std::string::npos )
|
if ((yysemantic_stack_[(4) - (1)]).find("OUT") != std::string::npos && (yysemantic_stack_[(4) - (1)]).find("INDEX") == std::string::npos )
|
{
|
{
|
//PopulateInstruction( "R0", "R0 . X X X",$3,I,yylloc);
|
//PopulateInstruction( "R0", "R0 . X X X",$3,I,yylloc);
|
|
|
I.SetCode(EOPERATION_OUT);
|
I.SetCode(EOPERATION_IO);
|
|
I.SetIOOperation( EIO_OMWRITE );
|
|
|
(yysemantic_stack_[(4) - (1)]).erase((yysemantic_stack_[(4) - (1)]).find("OUT"),3);
|
(yysemantic_stack_[(4) - (1)]).erase((yysemantic_stack_[(4) - (1)]).find("OUT"),3);
|
|
|
unsigned int ImmediateValue;
|
unsigned int ImmediateValue;
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << (yysemantic_stack_[(4) - (1)]);
|
ss << std::hex << (yysemantic_stack_[(4) - (1)]);
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
PopulateInstruction( (yysemantic_stack_[(4) - (3)]), "R0 OFFSET", "R0 OFFSET", I, yylloc, true, ImmediateValue );
|
PopulateInstruction( (yysemantic_stack_[(4) - (3)]), "R0 OFFSET", "R0 OFFSET", I, yylloc, true, ImmediateValue );
|
#ifdef DEBUG
|
#ifdef DEBUG
|
I.PrintFields();
|
I.PrintFields();
|
#endif
|
#endif
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
ResetTempRegisterIndex();
|
ResetTempRegisterIndex();
|
goto LABEL_EXPRESSION_DONE;
|
goto LABEL_EXPRESSION_DONE;
|
}
|
}
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
// This means this that the expression will write into the output memory
|
// This means this that the expression will write into the output memory
|
// variable index
|
// variable index
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
if ((yysemantic_stack_[(4) - (1)]).find("OUT") != std::string::npos && (yysemantic_stack_[(4) - (1)]).find("INDEX") != std::string::npos )
|
if ((yysemantic_stack_[(4) - (1)]).find("OUT") != std::string::npos && (yysemantic_stack_[(4) - (1)]).find("INDEX") != std::string::npos )
|
{
|
{
|
std::string Destination = (yysemantic_stack_[(4) - (1)]);
|
std::string Destination = (yysemantic_stack_[(4) - (1)]);
|
DCOUT << "!!!!!!!!!!!!!!!!!Destination " << Destination << "\n";
|
DCOUT << "!!!!!!!!!!!!!!!!!Destination " << Destination << "\n";
|
std::string IndexRegister = Destination.substr(Destination.find("INDEX")+5);
|
std::string IndexRegister = Destination.substr(Destination.find("INDEX")+5);
|
Destination.erase(Destination.find("INDEX"));
|
Destination.erase(Destination.find("INDEX"));
|
|
|
|
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
|
|
PopulateSourceRegisters( IndexRegister + " OFFSET ", (yysemantic_stack_[(4) - (3)]), I, mInstructions );
|
// PopulateSourceRegisters( IndexRegister + " OFFSET ", $3, I, mInstructions );
|
|
PopulateSourceRegisters( IndexRegister, (yysemantic_stack_[(4) - (3)]), I, mInstructions );
|
|
|
|
|
//I.SetImm( 0 );
|
//I.SetImm( 0 );
|
I.SetCode( EOPERATION_OUT );
|
I.SetCode( EOPERATION_IO );
|
|
I.SetIOOperation( EIO_OMWRITE );
|
|
|
std::string Source0 = (yysemantic_stack_[(4) - (3)]);
|
std::string Source0 = (yysemantic_stack_[(4) - (3)]);
|
DCOUT << "!!!!!!!!!!!!!!!!!Source0 '" << Source0 << "'\n";
|
DCOUT << "!!!!!!!!!!!!!!!!!Source0 '" << Source0 << "'\n";
|
/* if (Source0.find("OFFSET") != std::string::npos)
|
|
{
|
|
Source0.erase(Source0.find("OFFSET"));
|
|
I.SetSrc0Displace(1);
|
|
}
|
|
I.SetSrc1Address(atoi(IndexRegister.c_str()+1));
|
|
I.SetSrc0Address(atoi(Source0.c_str()+1));*/
|
|
|
|
/* if (Destination.find(".") != std::string::npos)
|
|
{
|
|
I.ClearWriteChannel();
|
|
if (Destination.find("x") != std::string::npos)
|
|
I.SetWriteChannel(ECHANNEL_X);
|
|
if (Destination.find("y") != std::string::npos)
|
|
I.SetWriteChannel(ECHANNEL_Y);
|
|
if (Destination.find("z") != std::string::npos)
|
|
I.SetWriteChannel(ECHANNEL_Z);
|
|
|
|
Destination.erase(Destination.find("."));
|
|
|
|
}
|
|
|
|
std::string Source0 = $3;
|
|
if (Source0.find("OFFSET") != std::string::npos)
|
|
{
|
|
Source0.erase(Source0.find("OFFSET"));
|
|
I.SetSrc0Displace(1);
|
|
}
|
|
I.SetSrc1Address(atoi(IndexRegister.c_str()+1));
|
|
I.SetSrc0Address(atoi(Source0.c_str()+1));
|
|
|
|
|
|
// I.SetSrc0Address(mInstructions.back().GetDestinationAddress());
|
|
I.SetDestZero(0);
|
|
I.SetSrc1Displace(1);
|
|
I.SetSrc0Displace(1);
|
|
I.SetDestinationAddress( atoi(Destination.c_str()+1) );*/
|
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
ResetTempRegisterIndex();
|
ResetTempRegisterIndex();
|
goto LABEL_EXPRESSION_DONE;
|
goto LABEL_EXPRESSION_DONE;
|
}
|
}
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
// This means this that the expression was just a constant.
|
// This means this that the expression was just a constant.
|
// No operations were inserted
|
// No operations were inserted
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
if (gInsertedInstructions == 0)
|
if (gInsertedInstructions == 0)
|
{
|
{
|
|
|
I.Clear();
|
I.Clear();
|
|
|
I.SetCode(EOPERATION_ADD);
|
I.SetCode(EOPERATION_ADD);
|
I.mSourceLine = GetCurrentLineNumber(yylloc);
|
I.mSourceLine = GetCurrentLineNumber(yylloc);
|
if ((yysemantic_stack_[(4) - (3)]).find("R") != std::string::npos)
|
if ((yysemantic_stack_[(4) - (3)]).find("R") != std::string::npos)
|
{
|
{
|
// case 1:
|
// case 1:
|
// foo = 0; //$$ = R0 . X X X
|
// foo = 0; //$$ = R0 . X X X
|
/* SetDestinationFromRegister( $1, I, false );
|
/* SetDestinationFromRegister( $1, I, false );
|
PopulateSourceRegisters( $3, "R0 . X X X", I, mInstructions);*/
|
PopulateSourceRegisters( $3, "R0 . X X X", I, mInstructions);*/
|
|
|
PopulateInstruction( (yysemantic_stack_[(4) - (1)]), "R0 . X X X",(yysemantic_stack_[(4) - (3)]),I,yylloc);
|
PopulateInstruction( (yysemantic_stack_[(4) - (1)]), "R0 . X X X",(yysemantic_stack_[(4) - (3)]),I,yylloc);
|
|
|
} else {
|
} else {
|
// case 2:
|
// case 2:
|
// foo = 0xcafe; //$$ = 0xcafe
|
// foo = 0xcafe; //$$ = 0xcafe
|
SetDestinationFromRegister( (yysemantic_stack_[(4) - (1)]), I, true );
|
SetDestinationFromRegister( (yysemantic_stack_[(4) - (1)]), I, true );
|
unsigned int ImmediateValue = 0;
|
unsigned int ImmediateValue = 0;
|
std::string StringHex = (yysemantic_stack_[(4) - (3)]);
|
std::string StringHex = (yysemantic_stack_[(4) - (3)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
|
|
PopulateInstruction( (yysemantic_stack_[(4) - (1)]), (yysemantic_stack_[(4) - (3)]),"NULL",I, yylloc, true, ImmediateValue);
|
PopulateInstruction( (yysemantic_stack_[(4) - (1)]), (yysemantic_stack_[(4) - (3)]),"NULL",I, yylloc, true, ImmediateValue);
|
}
|
}
|
std::string strConstant = (yysemantic_stack_[(4) - (3)]);
|
std::string strConstant = (yysemantic_stack_[(4) - (3)]);
|
|
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
ResetTempRegisterIndex();
|
ResetTempRegisterIndex();
|
goto LABEL_EXPRESSION_DONE;
|
goto LABEL_EXPRESSION_DONE;
|
}
|
}
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
// This means that the last instruction which was inserted was a tripple
|
// This means that the last instruction which was inserted was a tripple
|
// constant assignement, like foo = (1,2,3)
|
// constant assignement, like foo = (1,2,3)
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
if (mInstructions.back().mBisonFlagTrippleConstAssign)
|
if (mInstructions.back().mBisonFlagTrippleConstAssign)
|
{
|
{
|
unsigned int LastIndex = mInstructions.size() - 1;
|
unsigned int LastIndex = mInstructions.size() - 1;
|
mInstructions[LastIndex].SetDestinationAddress(atoi((yysemantic_stack_[(4) - (1)]).c_str()+1));
|
mInstructions[LastIndex].SetDestinationAddress(atoi((yysemantic_stack_[(4) - (1)]).c_str()+1));
|
mInstructions[LastIndex-1].SetDestinationAddress(atoi((yysemantic_stack_[(4) - (1)]).c_str()+1));
|
mInstructions[LastIndex-1].SetDestinationAddress(atoi((yysemantic_stack_[(4) - (1)]).c_str()+1));
|
mInstructions[LastIndex-2].SetDestinationAddress(atoi((yysemantic_stack_[(4) - (1)]).c_str()+1));
|
mInstructions[LastIndex-2].SetDestinationAddress(atoi((yysemantic_stack_[(4) - (1)]).c_str()+1));
|
mInstructions[LastIndex-2].mSourceLine = GetCurrentLineNumber( yylloc );
|
mInstructions[LastIndex-2].mSourceLine = GetCurrentLineNumber( yylloc );
|
if((yysemantic_stack_[(4) - (1)]).find("OFFSET") == std::string::npos)
|
if((yysemantic_stack_[(4) - (1)]).find("OFFSET") == std::string::npos)
|
{
|
{
|
mInstructions[LastIndex].SetAddressingMode(true,false,false);
|
mInstructions[LastIndex].SetAddressingMode(true,false,false);
|
mInstructions[LastIndex-1].SetAddressingMode(true,false,false);
|
mInstructions[LastIndex-1].SetAddressingMode(true,false,false);
|
mInstructions[LastIndex-2].SetAddressingMode(true,false,false);
|
mInstructions[LastIndex-2].SetAddressingMode(true,false,false);
|
}
|
}
|
|
|
ResetTempRegisterIndex();
|
ResetTempRegisterIndex();
|
goto LABEL_EXPRESSION_DONE;
|
goto LABEL_EXPRESSION_DONE;
|
}
|
}
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
// Handle the case where the destination is an array of vector
|
// Handle the case where the destination is an array of vector
|
// ej: R = v1[ i ] + V2
|
// ej: R = v1[ i ] + V2
|
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
if (I.GetOperation() == 0 && (yysemantic_stack_[(4) - (3)]).find("array_element") != std::string::npos)
|
if (I.GetOperation() == 0 && (yysemantic_stack_[(4) - (3)]).find("array_element") != std::string::npos)
|
{
|
{
|
//No operation meaning the the expression only has a single variable
|
//No operation meaning the the expression only has a single variable
|
//See if the expression returned is an array_element
|
//See if the expression returned is an array_element
|
if ((yysemantic_stack_[(4) - (3)]).find("array_element") != std::string::npos)
|
if ((yysemantic_stack_[(4) - (3)]).find("array_element") != std::string::npos)
|
{
|
{
|
////std::cout << "expression is an array element\n\n";
|
////std::cout << "expression is an array element\n\n";
|
std::string Index = (yysemantic_stack_[(4) - (3)]).substr((yysemantic_stack_[(4) - (3)]).find("array_element"));
|
std::string Index = (yysemantic_stack_[(4) - (3)]).substr((yysemantic_stack_[(4) - (3)]).find("array_element"));
|
Index = Index.substr(Index.find_first_not_of("array_element R"));
|
Index = Index.substr(Index.find_first_not_of("array_element R"));
|
SetIndexRegister( atoi(Index.c_str()), mInstructions );
|
SetIndexRegister( atoi(Index.c_str()), mInstructions );
|
(yysemantic_stack_[(4) - (3)]).erase((yysemantic_stack_[(4) - (3)]).find("array_element"));
|
(yysemantic_stack_[(4) - (3)]).erase((yysemantic_stack_[(4) - (3)]).find("array_element"));
|
SetExpressionDestination( (yysemantic_stack_[(4) - (1)]), I );
|
SetExpressionDestination( (yysemantic_stack_[(4) - (1)]), I );
|
I.SetCode(EOPERATION_ADD);
|
I.SetCode(EOPERATION_ADD);
|
I.SetImmBit( true );
|
I.SetImmBit( true );
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.SetSrc1Displace( true );
|
I.SetSrc1Displace( true );
|
I.SetSrc0Displace( false );
|
I.SetSrc0Displace( false );
|
I.mSourceLine = GetCurrentLineNumber(yylloc);
|
I.mSourceLine = GetCurrentLineNumber(yylloc);
|
|
|
if ((yysemantic_stack_[(4) - (3)]).find("OFFSET") != std::string::npos)
|
if ((yysemantic_stack_[(4) - (3)]).find("OFFSET") != std::string::npos)
|
(yysemantic_stack_[(4) - (3)]).erase((yysemantic_stack_[(4) - (3)]).find("OFFSET"));
|
(yysemantic_stack_[(4) - (3)]).erase((yysemantic_stack_[(4) - (3)]).find("OFFSET"));
|
|
|
I.SetSrc1Address(atoi((yysemantic_stack_[(4) - (3)]).c_str()+1));
|
I.SetSrc1Address(atoi((yysemantic_stack_[(4) - (3)]).c_str()+1));
|
I.SetSrc0Address(0);
|
I.SetSrc0Address(0);
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
}
|
}
|
}
|
}
|
else
|
else
|
{
|
{
|
|
|
mInstructions[ mInstructions.size() - gInsertedInstructions].mSourceLine = GetCurrentLineNumber(yylloc);
|
mInstructions[ mInstructions.size() - gInsertedInstructions].mSourceLine = GetCurrentLineNumber(yylloc);
|
gInsertedInstructions = 0;
|
gInsertedInstructions = 0;
|
std::string Destination = (yysemantic_stack_[(4) - (1)]);
|
std::string Destination = (yysemantic_stack_[(4) - (1)]);
|
//std::cout << "DST " << Destination << " \n";
|
//std::cout << "DST " << Destination << " \n";
|
//Look for indirect addressing
|
//Look for indirect addressing
|
if (Destination.find("INDEX") != std::string::npos)
|
if (Destination.find("INDEX") != std::string::npos)
|
{
|
{
|
|
|
std::string IndexRegister = Destination.substr(Destination.find("INDEX")+5);
|
std::string IndexRegister = Destination.substr(Destination.find("INDEX")+5);
|
|
|
Destination.erase(Destination.find("INDEX"));
|
Destination.erase(Destination.find("INDEX"));
|
|
|
I.SetImm( 0 );
|
I.SetImm( 0 );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
|
|
if (Destination.find(".") != std::string::npos)
|
if (Destination.find(".") != std::string::npos)
|
{
|
{
|
I.ClearWriteChannel();
|
I.ClearWriteChannel();
|
if (Destination.find("x") != std::string::npos)
|
if (Destination.find("x") != std::string::npos)
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
if (Destination.find("y") != std::string::npos)
|
if (Destination.find("y") != std::string::npos)
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetWriteChannel(ECHANNEL_Y);
|
if (Destination.find("z") != std::string::npos)
|
if (Destination.find("z") != std::string::npos)
|
I.SetWriteChannel(ECHANNEL_Z);
|
I.SetWriteChannel(ECHANNEL_Z);
|
|
|
Destination.erase(Destination.find("."));
|
Destination.erase(Destination.find("."));
|
|
|
}
|
}
|
|
|
std::string Source0 = (yysemantic_stack_[(4) - (3)]);
|
std::string Source0 = (yysemantic_stack_[(4) - (3)]);
|
if (Source0.find("OFFSET") != std::string::npos)
|
if (Source0.find("OFFSET") != std::string::npos)
|
{
|
{
|
Source0.erase(Source0.find("OFFSET"));
|
Source0.erase(Source0.find("OFFSET"));
|
I.SetSrc0Displace(1);
|
I.SetSrc0Displace(1);
|
}
|
}
|
I.SetSrc1Address(atoi(IndexRegister.c_str()+1));
|
I.SetSrc1Address(atoi(IndexRegister.c_str()+1));
|
I.SetSrc0Address(atoi(Source0.c_str()+1));
|
I.SetSrc0Address(atoi(Source0.c_str()+1));
|
|
|
|
|
// I.SetSrc0Address(mInstructions.back().GetDestinationAddress());
|
// I.SetSrc0Address(mInstructions.back().GetDestinationAddress());
|
I.SetDestZero(0);
|
I.SetDestZero(0);
|
I.SetSrc1Displace(1);
|
I.SetSrc1Displace(1);
|
I.SetSrc0Displace(1);
|
I.SetSrc0Displace(1);
|
I.SetDestinationAddress( atoi(Destination.c_str()+1) );
|
I.SetDestinationAddress( atoi(Destination.c_str()+1) );
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
} else {
|
} else {
|
|
|
if (mInstructions.back().GetImm())
|
if (mInstructions.back().GetImm())
|
{
|
{
|
//Look for displament addressing mode
|
//Look for displament addressing mode
|
unsigned int AddressingMode = mInstructions.back().GetAddressingMode();
|
unsigned int AddressingMode = mInstructions.back().GetAddressingMode();
|
if (Destination.find("OFFSET") != std::string::npos)
|
if (Destination.find("OFFSET") != std::string::npos)
|
{
|
{
|
//This means AddressMode is '101', so leave the way it is
|
//This means AddressMode is '101', so leave the way it is
|
mInstructions.back().ClearWriteChannel();
|
mInstructions.back().ClearWriteChannel();
|
mInstructions.back().SetWriteChannel(ECHANNEL_Z);
|
mInstructions.back().SetWriteChannel(ECHANNEL_Z);
|
Destination.erase(Destination.find("OFFSET"));
|
Destination.erase(Destination.find("OFFSET"));
|
} else {
|
} else {
|
//This is not supposed to have index, so change addressing mode to '100'
|
//This is not supposed to have index, so change addressing mode to '100'
|
|
|
mInstructions.back().SetDestZero( true );
|
mInstructions.back().SetDestZero( true );
|
mInstructions.back().SetSrc1Displace( false );
|
mInstructions.back().SetSrc1Displace( false );
|
mInstructions.back().SetSrc0Displace( false );
|
mInstructions.back().SetSrc0Displace( false );
|
mInstructions.back().ClearWriteChannel();
|
mInstructions.back().ClearWriteChannel();
|
mInstructions.back().SetWriteChannel(ECHANNEL_Z);
|
mInstructions.back().SetWriteChannel(ECHANNEL_Z);
|
}
|
}
|
|
|
} else {
|
} else {
|
mInstructions.back().SetDestZero( false ); //First assume no offset was used
|
mInstructions.back().SetDestZero( false ); //First assume no offset was used
|
|
|
|
|
|
|
//Look for displament addressing mode
|
//Look for displament addressing mode
|
if (Destination.find("OFFSET") != std::string::npos)
|
if (Destination.find("OFFSET") != std::string::npos)
|
{
|
{
|
Destination.erase(Destination.find("OFFSET"));
|
Destination.erase(Destination.find("OFFSET"));
|
mInstructions.back().SetDestZero( true ); //When Imm != 0, DestZero means DST = DSTINDEX + offset
|
mInstructions.back().SetDestZero( true ); //When Imm != 0, DestZero means DST = DSTINDEX + offset
|
}
|
}
|
}
|
}
|
if (Destination.find(".") != std::string::npos)
|
if (Destination.find(".") != std::string::npos)
|
{
|
{
|
mInstructions.back().ClearWriteChannel();
|
mInstructions.back().ClearWriteChannel();
|
if (Destination.find("x") != std::string::npos)
|
if (Destination.find("x") != std::string::npos)
|
mInstructions.back().SetWriteChannel(ECHANNEL_X);
|
mInstructions.back().SetWriteChannel(ECHANNEL_X);
|
if (Destination.find("y") != std::string::npos)
|
if (Destination.find("y") != std::string::npos)
|
mInstructions.back().SetWriteChannel(ECHANNEL_Y);
|
mInstructions.back().SetWriteChannel(ECHANNEL_Y);
|
if (Destination.find("z") != std::string::npos)
|
if (Destination.find("z") != std::string::npos)
|
mInstructions.back().SetWriteChannel(ECHANNEL_Z);
|
mInstructions.back().SetWriteChannel(ECHANNEL_Z);
|
|
|
Destination.erase(Destination.find("."));
|
Destination.erase(Destination.find("."));
|
|
|
}
|
}
|
mInstructions.back().SetDestinationAddress( atoi((yysemantic_stack_[(4) - (1)]).c_str()+1) );
|
mInstructions.back().SetDestinationAddress( atoi((yysemantic_stack_[(4) - (1)]).c_str()+1) );
|
for (int i = 1; i <= gExtraDestModifications; i++ )
|
for (int i = 1; i <= gExtraDestModifications; i++ )
|
{
|
{
|
int idx = (mInstructions.size()-1)-i;
|
int idx = (mInstructions.size()-1)-i;
|
mInstructions[idx].SetDestinationAddress( atoi((yysemantic_stack_[(4) - (1)]).c_str()+1) );
|
mInstructions[idx].SetDestinationAddress( atoi((yysemantic_stack_[(4) - (1)]).c_str()+1) );
|
if (mInstructions[idx].GetImm())
|
if (mInstructions[idx].GetImm())
|
{
|
{
|
|
|
//This is not supposed to have index, so change addressing mode to '100'
|
//This is not supposed to have index, so change addressing mode to '100'
|
mInstructions[idx].SetDestZero( true );
|
mInstructions[idx].SetDestZero( true );
|
mInstructions[idx].SetSrc1Displace( false );
|
mInstructions[idx].SetSrc1Displace( false );
|
mInstructions[idx].SetSrc0Displace( false );
|
mInstructions[idx].SetSrc0Displace( false );
|
|
|
|
|
}
|
}
|
|
|
}
|
}
|
gExtraDestModifications = 0;
|
gExtraDestModifications = 0;
|
|
|
|
|
|
|
}
|
}
|
ResetTempRegisterIndex();
|
ResetTempRegisterIndex();
|
}
|
}
|
|
|
LABEL_EXPRESSION_DONE:
|
LABEL_EXPRESSION_DONE:
|
gInsertedInstructions = 0;
|
gInsertedInstructions = 0;
|
while(0);
|
while(0);
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 14:
|
case 14:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1343 "parser.y"
|
#line 1358 "parser.y"
|
{ /*Middle rule here, get me the loop address*/ ;gWhileLoopAddress = (mInstructions.size());}
|
{ /*Middle rule here, get me the loop address*/ ;gWhileLoopAddress = (mInstructions.size());}
|
break;
|
break;
|
|
|
case 15:
|
case 15:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1344 "parser.y"
|
#line 1359 "parser.y"
|
{
|
{
|
mInstructions[gBranchStack.back()].SetDestinationAddress(mInstructions.size()+1);
|
mInstructions[gBranchStack.back()].SetDestinationAddress(mInstructions.size()+1);
|
gBranchStack.pop_back();
|
gBranchStack.pop_back();
|
//Now I need to put a GOTO so that the while gets evaluated again...
|
//Now I need to put a GOTO so that the while gets evaluated again...
|
//jump out of the if
|
//jump out of the if
|
I.Clear();
|
I.Clear();
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "while loop goto re-eval boolean";
|
I.mComment = "while loop goto re-eval boolean";
|
I.SetDestinationAddress( gWhileLoopAddress );
|
I.SetDestinationAddress( gWhileLoopAddress );
|
I.SetBranchFlag( true );
|
I.SetBranchFlag( true );
|
I.SetBranchType( EBRANCH_ALWAYS );
|
I.SetBranchType( EBRANCH_ALWAYS );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 16:
|
case 16:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1363 "parser.y"
|
#line 1390 "parser.y"
|
{
|
{ //Start of middle rule
|
|
|
//jump out of the if
|
//jump out of the if
|
I.Clear();
|
I.Clear();
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.SetBranchFlag( true );
|
I.SetBranchFlag( true );
|
I.SetBranchType( EBRANCH_ALWAYS );
|
I.SetBranchType( EBRANCH_ALWAYS );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
//Take care of the destination addr of the if statement.
|
//Take care of the destination addr of the if statement.
|
mInstructions[gBranchStack.back()].SetDestinationAddress(mInstructions.size());
|
mInstructions[gBranchStack.back()].SetDestinationAddress(mInstructions.size());
|
gBranchStack.pop_back();
|
gBranchStack.pop_back();
|
//push the inconditional jump into the stack
|
//push the inconditional jump into the stack
|
gBranchStack.push_back(mInstructions.size() - 1);
|
gBranchStack.push_back(mInstructions.size() - 1);
|
////std::cout << "else\n";
|
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 17:
|
case 17:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1381 "parser.y"
|
#line 1408 "parser.y"
|
{
|
{
|
|
|
mInstructions[gBranchStack.back()].SetDestinationAddress(mInstructions.size());
|
mInstructions[gBranchStack.back()].SetDestinationAddress(mInstructions.size());
|
gBranchStack.pop_back();
|
gBranchStack.pop_back();
|
//Now push the JMP
|
|
|
|
////std::cout << "END elseif\n";
|
|
}
|
}
|
break;
|
break;
|
|
|
case 18:
|
case 18:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1392 "parser.y"
|
#line 1426 "parser.y"
|
{
|
{
|
mInstructions[gBranchStack.back()].SetDestinationAddress(mInstructions.size());
|
mInstructions[gBranchStack.back()].SetDestinationAddress(mInstructions.size());
|
//mInstructions[gBranchStack.back()].mSourceLine = GetCurrentLineNumber(yylloc);
|
//mInstructions[gBranchStack.back()].mSourceLine = GetCurrentLineNumber(yylloc);
|
|
|
gBranchStack.pop_back();
|
gBranchStack.pop_back();
|
////std::cout << "if closing at " << mInstructions.size() << "\n";
|
////std::cout << "if closing at " << mInstructions.size() << "\n";
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 19:
|
case 19:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1402 "parser.y"
|
#line 1446 "parser.y"
|
{
|
{
|
////std::cout << "Function declaration for " << $2 << " at " << mInstructions.size() << "\n" ;
|
DCOUT << "Function declaration for " << (yysemantic_stack_[(5) - (2)]) << " at " << mInstructions.size() << "\n" ;
|
mSymbolMap[ (yysemantic_stack_[(5) - (2)]) ] = mInstructions.size();
|
mSymbolMap[ (yysemantic_stack_[(5) - (2)]) ] = mInstructions.size();
|
}
|
}
|
break;
|
break;
|
|
|
case 20:
|
case 20:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1406 "parser.y"
|
#line 1450 "parser.y"
|
{
|
{
|
//Clear the auto var index now that we leave the function scope
|
//Clear the auto var index now that we leave the function scope
|
ClearAutoVarMap();
|
ClearAutoVarMap();
|
ClearFunctionParameterMap();
|
ClearFunctionParameterMap();
|
|
|
//Now uddate the current SPR_CONTROL_REGISTER.x = SPR_CONTROL_REGISTER.y
|
//Now uddate the current SPR_CONTROL_REGISTER.x = SPR_CONTROL_REGISTER.y
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "Restore previous function frame offset";
|
I.mComment = "Restore previous function frame offset";
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetSrc1Address(SPR_CONTROL_REGISTER);
|
I.SetSrc1Address(SPR_CONTROL_REGISTER);
|
I.SetSrc1SwizzleX(SWX_Y);
|
I.SetSrc1SwizzleX(SWX_Y);
|
I.SetSrc1SwizzleY(SWY_Y);
|
I.SetSrc1SwizzleY(SWY_Y);
|
I.SetSrc1SwizzleZ(SWZ_Y);
|
I.SetSrc1SwizzleZ(SWZ_Y);
|
I.SetSrc0Address(0);
|
I.SetSrc0Address(0);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
|
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
}
|
}
|
break;
|
break;
|
|
|
case 21:
|
case 21:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1431 "parser.y"
|
#line 1485 "parser.y"
|
{
|
{
|
gThreadMap[ (yysemantic_stack_[(4) - (2)]) ] = mInstructions.size();
|
gThreadMap[ (yysemantic_stack_[(4) - (2)]) ] = mInstructions.size();
|
gThreadScope = true;
|
gThreadScope = true;
|
}
|
}
|
break;
|
break;
|
|
|
case 22:
|
case 22:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1436 "parser.y"
|
#line 1490 "parser.y"
|
{
|
{
|
////std::cout << "Defining thread" << "\n";
|
////std::cout << "Defining thread" << "\n";
|
gThreadScope = false;
|
gThreadScope = false;
|
ClearAutoVarMap();
|
ClearAutoVarMap();
|
//Since the thread is done, then disable threading
|
//Since the thread is done, then disable threading
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "Disable multi-threading";
|
I.mComment = "Disable multi-threading";
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER0 );
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER0 );
|
unsigned int Value = 0;
|
unsigned int Value = 0;
|
I.SetImm( Value );
|
I.SetImm( Value );
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.SetWriteChannel(ECHANNEL_Z);
|
I.SetWriteChannel(ECHANNEL_Z);
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 23:
|
case 23:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1454 "parser.y"
|
#line 1516 "parser.y"
|
{
|
{
|
unsigned int ThreadCodeOffset = 0;
|
unsigned int ThreadCodeOffset = 0;
|
////std::cout << "Starting thread" << "\n";
|
////std::cout << "Starting thread" << "\n";
|
if (gThreadMap.find((yysemantic_stack_[(5) - (2)])) == gThreadMap.end())
|
if (gThreadMap.find((yysemantic_stack_[(5) - (2)])) == gThreadMap.end())
|
{
|
{
|
|
|
std::ostringstream ret;
|
std::ostringstream ret;
|
ret << "Undefined thread '" << (yysemantic_stack_[(5) - (2)]) << "' at line " << yylloc << " \n";
|
ret << "Undefined thread '" << (yysemantic_stack_[(5) - (2)]) << "' at line " << yylloc << " \n";
|
ret << "Current version of the compiler needs thread defintion prior of thread instantiation\n";
|
ret << "Current version of the compiler needs thread defintion prior of thread instantiation\n";
|
throw ret.str();
|
throw ret.str();
|
} else {
|
} else {
|
ThreadCodeOffset = gThreadMap[(yysemantic_stack_[(5) - (2)])];
|
ThreadCodeOffset = gThreadMap[(yysemantic_stack_[(5) - (2)])];
|
//Now enable the multithreading and set instruction offset
|
//Now enable the multithreading and set instruction offset
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
std::ostringstream ss;
|
std::ostringstream ss;
|
ss << "Set thread instruction offset to 8'd" << ThreadCodeOffset;
|
ss << "Set thread instruction offset to 8'd" << ThreadCodeOffset;
|
I.mComment = ss.str();
|
I.mComment = ss.str();
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER0 );
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER0 );
|
unsigned int Value = (ThreadCodeOffset << 1);
|
unsigned int Value = (ThreadCodeOffset << 1);
|
I.SetImm( Value );
|
I.SetImm( Value );
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.SetWriteChannel(ECHANNEL_Z);
|
I.SetWriteChannel(ECHANNEL_Z);
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
|
|
|
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "Enable multi-threading";
|
I.mComment = "Enable multi-threading";
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER0 );
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER0 );
|
Value = (ThreadCodeOffset << 1 | 1);
|
Value = (ThreadCodeOffset << 1 | 1);
|
I.SetImm( Value );
|
I.SetImm( Value );
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.SetWriteChannel(ECHANNEL_Z);
|
I.SetWriteChannel(ECHANNEL_Z);
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
|
|
}
|
}
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 24:
|
case 24:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1495 "parser.y"
|
#line 1565 "parser.y"
|
{
|
{
|
////std::cout << "Function call returning to var\n";
|
////std::cout << "Function call returning to var\n";
|
StoreReturnAddress( mInstructions, yylloc );
|
StoreReturnAddress( mInstructions, yylloc );
|
SavePreviousFramePointer( mInstructions );
|
SavePreviousFramePointer( mInstructions );
|
UpdateFramePointer( mInstructions );
|
UpdateFramePointer( mInstructions );
|
CallFunction( (yysemantic_stack_[(7) - (3)]), mInstructions, mSymbolMap );
|
CallFunction( (yysemantic_stack_[(7) - (3)]), mInstructions, mSymbolMap );
|
|
|
|
|
//Return value comes in R1, so let's store this in our variable
|
//Return value comes in R1, so let's store this in our variable
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
SetDestinationFromRegister( (yysemantic_stack_[(7) - (1)]), I, false );
|
SetDestinationFromRegister( (yysemantic_stack_[(7) - (1)]), I, false );
|
I.mComment = "grab the return value from the function";
|
I.mComment = "grab the return value from the function";
|
I.SetSrc1Address( RETURN_VALUE_REGISTER);
|
I.SetSrc1Address( RETURN_VALUE_REGISTER);
|
I.SetSrc0Address(0);
|
I.SetSrc0Address(0);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
ClearNextFunctionParamRegister();
|
ClearNextFunctionParamRegister();
|
}
|
}
|
break;
|
break;
|
|
|
case 25:
|
case 25:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1519 "parser.y"
|
#line 1596 "parser.y"
|
{
|
{
|
|
|
//Store the return address
|
//Store the return address
|
StoreReturnAddress( mInstructions, yylloc );
|
StoreReturnAddress( mInstructions, yylloc );
|
|
|
|
|
//Store the current SPR_CONTROL_REGISTER.x into the previous SPR_CONTROL_REGISTER.y
|
//Store the current SPR_CONTROL_REGISTER.x into the previous SPR_CONTROL_REGISTER.y
|
//SPR_CONTROL_REGISTER.y = SPR_CONTROL_REGISTER.xxx + 0;
|
//SPR_CONTROL_REGISTER.y = SPR_CONTROL_REGISTER.xxx + 0;
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "store current frame offset";
|
I.mComment = "store current frame offset";
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetSrc1Address(SPR_CONTROL_REGISTER);
|
I.SetSrc1Address(SPR_CONTROL_REGISTER);
|
I.SetSrc1SwizzleX(SWX_X);
|
I.SetSrc1SwizzleX(SWX_X);
|
I.SetSrc1SwizzleY(SWY_X);
|
I.SetSrc1SwizzleY(SWY_X);
|
I.SetSrc1SwizzleZ(SWZ_X);
|
I.SetSrc1SwizzleZ(SWZ_X);
|
I.SetSrc0Address(0);
|
I.SetSrc0Address(0);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleX(SWX_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleY(SWY_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
I.SetSrc0SwizzleZ(SWZ_X);
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
//Now uddate the current SPR_CONTROL_REGISTER.x += number of auto variables
|
//Now uddate the current SPR_CONTROL_REGISTER.x += number of auto variables
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "displace next frame offset by the number of auto variables in current frame";
|
I.mComment = "displace next frame offset by the number of auto variables in current frame";
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetDestinationAddress( SPR_CONTROL_REGISTER );
|
I.SetImm( GetCurretAutoVarFrameSize() );
|
I.SetImm( GetCurretAutoVarFrameSize() );
|
I.SetDestZero( false );
|
I.SetDestZero( false );
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
//Call the function with a JMP
|
//Call the function with a JMP
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mComment = "call the function";
|
I.mComment = "call the function";
|
I.SetBranchFlag( true );
|
I.SetBranchFlag( true );
|
I.SetBranchType( EBRANCH_ALWAYS );
|
I.SetBranchType( EBRANCH_ALWAYS );
|
//Now do the branch
|
|
|
//Now assign the destination of the branch (our function virtual address)
|
if (mSymbolMap.find((yysemantic_stack_[(5) - (1)])) == mSymbolMap.end())
|
if (mSymbolMap.find((yysemantic_stack_[(5) - (1)])) == mSymbolMap.end())
|
{
|
{
|
// ////std::cout << "Error in line : " << $1 <<" undelcared IDENTIFIER\n";
|
//The destination is not yet declared
|
|
//so leave it as a symbol so that it can latter
|
|
//resolved by the linker
|
I.SetDestinationSymbol( "@"+(yysemantic_stack_[(5) - (1)]) );
|
I.SetDestinationSymbol( "@"+(yysemantic_stack_[(5) - (1)]) );
|
// exit(1);
|
|
} else {
|
} else {
|
|
//The destination symbol has already been declared
|
|
//so assign it right away
|
I.SetDestinationAddress( mSymbolMap[ (yysemantic_stack_[(5) - (1)]) ] );
|
I.SetDestinationAddress( mSymbolMap[ (yysemantic_stack_[(5) - (1)]) ] );
|
}
|
}
|
|
|
|
//Push the last instruction in the sequence and clean up
|
mInstructions.push_back( I );
|
mInstructions.push_back( I );
|
I.Clear();
|
I.Clear();
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 27:
|
case 27:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1578 "parser.y"
|
#line 1659 "parser.y"
|
{
|
{
|
AddFunctionInputList( (yysemantic_stack_[(3) - (1)]), mInstructions,yylloc );
|
AddFunctionInputList( (yysemantic_stack_[(3) - (1)]), mInstructions,yylloc );
|
}
|
}
|
break;
|
break;
|
|
|
case 28:
|
case 28:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1583 "parser.y"
|
#line 1664 "parser.y"
|
{
|
{
|
AddFunctionInputList( (yysemantic_stack_[(1) - (1)]),mInstructions, yylloc );
|
AddFunctionInputList( (yysemantic_stack_[(1) - (1)]),mInstructions, yylloc );
|
}
|
}
|
break;
|
break;
|
|
|
case 30:
|
case 30:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1592 "parser.y"
|
#line 1673 "parser.y"
|
{
|
{
|
AddFunctionParameter( (yysemantic_stack_[(3) - (1)]), yylloc );
|
AddFunctionParameter( (yysemantic_stack_[(3) - (1)]), yylloc );
|
}
|
}
|
break;
|
break;
|
|
|
case 31:
|
case 31:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1597 "parser.y"
|
#line 1678 "parser.y"
|
{
|
{
|
AddFunctionParameter( (yysemantic_stack_[(1) - (1)]), yylloc );
|
AddFunctionParameter( (yysemantic_stack_[(1) - (1)]), yylloc );
|
}
|
}
|
break;
|
break;
|
|
|
case 32:
|
case 32:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1618 "parser.y"
|
#line 1709 "parser.y"
|
{
|
{
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
gExtraDestModifications = 0;
|
gExtraDestModifications = 0;
|
|
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
|
|
PopulateSourceRegisters( (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions );
|
PopulateSourceRegisters( (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
gInsertedInstructions++;
|
gInsertedInstructions++;
|
I.Clear();
|
I.Clear();
|
|
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << "R" << TempRegIndex << " OFFSET ";
|
ss << "R" << TempRegIndex << " OFFSET ";
|
(yyval) = ss.str();
|
(yyval) = ss.str();
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 33:
|
case 33:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1639 "parser.y"
|
#line 1730 "parser.y"
|
{
|
{
|
gExtraDestModifications = 0;
|
gExtraDestModifications = 0;
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetSrc0SignX( true );
|
I.SetSrc0SignX( true );
|
I.SetSrc0SignY( true );
|
I.SetSrc0SignY( true );
|
I.SetSrc0SignZ( true );
|
I.SetSrc0SignZ( true );
|
|
|
PopulateSourceRegisters( (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions);
|
PopulateSourceRegisters( (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions);
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
gInsertedInstructions++;
|
gInsertedInstructions++;
|
I.Clear();
|
I.Clear();
|
|
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << "R" << TempRegIndex << " OFFSET ";
|
ss << "R" << TempRegIndex << " OFFSET ";
|
(yyval) = ss.str();
|
(yyval) = ss.str();
|
}
|
}
|
break;
|
break;
|
|
|
case 34:
|
case 34:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1661 "parser.y"
|
#line 1752 "parser.y"
|
{
|
{
|
gExtraDestModifications = 0;
|
gExtraDestModifications = 0;
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetCode( EOPERATION_LOGIC );
|
I.SetCode( EOPERATION_LOGIC );
|
I.SetLogicOperation( ELOGIC_OR );
|
I.SetLogicOperation( ELOGIC_OR );
|
PopulateSourceRegisters( (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions);
|
PopulateSourceRegisters( (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions);
|
|
|
|
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
gInsertedInstructions++;
|
gInsertedInstructions++;
|
I.Clear();
|
I.Clear();
|
|
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << "R" << TempRegIndex << " OFFSET ";
|
ss << "R" << TempRegIndex << " OFFSET ";
|
(yyval) = ss.str();
|
(yyval) = ss.str();
|
}
|
}
|
break;
|
break;
|
|
|
case 35:
|
case 35:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1682 "parser.y"
|
#line 1782 "parser.y"
|
{
|
{
|
(yyval) = (yysemantic_stack_[(1) - (1)]);
|
std::string Register;
|
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(4) - (3)]))) != "NULL")
|
|
(yyval) = "IN " + Register;
|
|
else
|
|
(yyval) = "IN " + GetRegisterFromAutoVar( (yysemantic_stack_[(4) - (3)]), yylloc ) + " OFFSET ";
|
}
|
}
|
break;
|
break;
|
|
|
case 36:
|
case 36:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1690 "parser.y"
|
#line 1791 "parser.y"
|
|
{
|
|
(yyval) = (yysemantic_stack_[(1) - (1)]);
|
|
}
|
|
break;
|
|
|
|
case 37:
|
|
|
|
/* Line 678 of lalr1.cc */
|
|
#line 1799 "parser.y"
|
{
|
{
|
gExtraDestModifications = 0;
|
gExtraDestModifications = 0;
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetCode( EOPERATION_MUL );
|
I.SetCode( EOPERATION_MUL );
|
|
|
PopulateSourceRegisters( (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions);
|
PopulateSourceRegisters( (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions);
|
|
|
//If we are using fixed point aritmethic then we need to apply the scale
|
//If we are using fixed point aritmethic then we need to apply the scale
|
//R = A * ( B >> SCALE)
|
//R = A * ( B >> SCALE)
|
if (mGenerateFixedPointArithmetic)
|
if (mGenerateFixedPointArithmetic)
|
I.SetSrc0Rotation( EROT_RESULT_RIGHT );
|
I.SetSrc0Rotation( EROT_RESULT_RIGHT );
|
|
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
gInsertedInstructions++;
|
gInsertedInstructions++;
|
I.Clear();
|
I.Clear();
|
|
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << "R" << TempRegIndex << " OFFSET ";
|
ss << "R" << TempRegIndex << " OFFSET ";
|
(yyval) = ss.str();
|
(yyval) = ss.str();
|
}
|
}
|
break;
|
break;
|
|
|
case 37:
|
case 38:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1715 "parser.y"
|
#line 1824 "parser.y"
|
{
|
{
|
gExtraDestModifications = 0;
|
gExtraDestModifications = 0;
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetCode( EOPERATION_DIV );
|
I.SetCode( EOPERATION_DIV );
|
|
|
PopulateSourceRegisters( (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions);
|
PopulateSourceRegisters( (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions);
|
|
|
//If we are using fixed point aritmethic then we need to apply the scale
|
//If we are using fixed point aritmethic then we need to apply the scale
|
// R = (A << N) / B
|
// R = (A << N) / B
|
if (mGenerateFixedPointArithmetic)
|
if (mGenerateFixedPointArithmetic)
|
I.SetSrc1Rotation( EROT_SRC1_LEFT );
|
I.SetSrc1Rotation( EROT_SRC1_LEFT );
|
|
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
gInsertedInstructions++;
|
gInsertedInstructions++;
|
I.Clear();
|
I.Clear();
|
|
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << "R" << TempRegIndex << " OFFSET ";
|
ss << "R" << TempRegIndex << " OFFSET ";
|
(yyval) = ss.str();
|
(yyval) = ss.str();
|
}
|
}
|
break;
|
break;
|
|
|
case 38:
|
case 39:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1740 "parser.y"
|
#line 1849 "parser.y"
|
{
|
{
|
gExtraDestModifications = 0;
|
gExtraDestModifications = 0;
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetCode( EOPERATION_LOGIC );
|
I.SetCode( EOPERATION_LOGIC );
|
I.SetLogicOperation( ELOGIC_AND );
|
I.SetLogicOperation( ELOGIC_AND );
|
PopulateSourceRegisters( (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions);
|
PopulateSourceRegisters( (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions);
|
|
|
|
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
gInsertedInstructions++;
|
gInsertedInstructions++;
|
I.Clear();
|
I.Clear();
|
|
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << "R" << TempRegIndex << " OFFSET ";
|
ss << "R" << TempRegIndex << " OFFSET ";
|
(yyval) = ss.str();
|
(yyval) = ss.str();
|
}
|
}
|
break;
|
break;
|
|
|
case 39:
|
case 40:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1761 "parser.y"
|
#line 1870 "parser.y"
|
{
|
{
|
(yyval) = (yysemantic_stack_[(1) - (1)]);
|
(yyval) = (yysemantic_stack_[(1) - (1)]);
|
}
|
}
|
break;
|
break;
|
|
|
case 40:
|
case 41:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1769 "parser.y"
|
#line 1878 "parser.y"
|
{
|
{
|
(yyval) = (yysemantic_stack_[(1) - (1)]);
|
(yyval) = (yysemantic_stack_[(1) - (1)]);
|
}
|
}
|
break;
|
break;
|
|
|
case 41:
|
case 42:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1774 "parser.y"
|
#line 1888 "parser.y"
|
{
|
{
|
gExtraDestModifications = 0;
|
gExtraDestModifications = 0;
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetDestZero( true ); //Use indexing for DST
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetWriteChannel(ECHANNEL_XYZ);
|
I.SetCode( EOPERATION_SQRT );
|
I.SetCode( EOPERATION_SQRT );
|
I.SetSrc0Address( 0 );
|
I.SetSrc0Address( 0 );
|
PopulateSourceRegisters( (yysemantic_stack_[(4) - (3)]) ,"R0 . X X X", I, mInstructions);
|
PopulateSourceRegisters( (yysemantic_stack_[(4) - (3)]) ,"R0 . X X X", I, mInstructions);
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
gInsertedInstructions++;
|
gInsertedInstructions++;
|
I.Clear();
|
I.Clear();
|
|
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << "R" << TempRegIndex << " OFFSET ";
|
ss << "R" << TempRegIndex << " OFFSET ";
|
(yyval) = ss.str();
|
(yyval) = ss.str();
|
}
|
}
|
break;
|
break;
|
|
|
case 42:
|
case 43:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1793 "parser.y"
|
#line 1907 "parser.y"
|
{
|
{
|
(yyval) = (yysemantic_stack_[(3) - (2)]);
|
(yyval) = (yysemantic_stack_[(3) - (2)]);
|
}
|
}
|
break;
|
break;
|
|
|
case 43:
|
case 44:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1803 "parser.y"
|
#line 1917 "parser.y"
|
{
|
{
|
|
|
unsigned int ImmediateValue;
|
unsigned int ImmediateValue;
|
std::string StringHex = (yysemantic_stack_[(1) - (1)]);
|
std::string StringHex = (yysemantic_stack_[(1) - (1)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
|
|
switch (ImmediateValue)
|
switch (ImmediateValue)
|
{
|
{
|
case 0:
|
case 0:
|
(yyval) = "R0 . X X X";
|
(yyval) = "R0 . X X X";
|
break;
|
break;
|
case 1:
|
case 1:
|
(yyval) = "R0 . Y Y Y";
|
(yyval) = "R0 . Y Y Y";
|
break;
|
break;
|
case 2:
|
case 2:
|
(yyval) = "R0 . Z Z Z";
|
(yyval) = "R0 . Z Z Z";
|
break;
|
break;
|
default:
|
default:
|
std::string StringHex = (yysemantic_stack_[(1) - (1)]);
|
std::string StringHex = (yysemantic_stack_[(1) - (1)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
(yyval) = ss.str();
|
(yyval) = ss.str();
|
break;
|
break;
|
}
|
}
|
}
|
}
|
break;
|
break;
|
|
|
case 44:
|
case 45:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1833 "parser.y"
|
#line 1947 "parser.y"
|
{
|
{
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
unsigned int TempRegIndex = GetFreeTempRegister();
|
unsigned int ImmediateValue;
|
unsigned int ImmediateValue;
|
|
|
{
|
{
|
|
|
std::string StringHex = (yysemantic_stack_[(7) - (2)]);
|
std::string StringHex = (yysemantic_stack_[(7) - (2)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
|
|
|
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetImm( ImmediateValue );
|
I.SetImm( ImmediateValue );
|
I.SetDestZero(true);
|
I.SetDestZero(true);
|
I.SetSrc0Displace(true);
|
I.SetSrc0Displace(true);
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
gInsertedInstructions++;
|
gInsertedInstructions++;
|
I.Clear();
|
I.Clear();
|
}
|
}
|
|
|
{
|
{
|
std::string StringHex = (yysemantic_stack_[(7) - (4)]);
|
std::string StringHex = (yysemantic_stack_[(7) - (4)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
|
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetImm( ImmediateValue );
|
I.SetImm( ImmediateValue );
|
I.SetDestZero(true);
|
I.SetDestZero(true);
|
I.SetSrc0Displace(true);
|
I.SetSrc0Displace(true);
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
gInsertedInstructions++;
|
gInsertedInstructions++;
|
I.Clear();
|
I.Clear();
|
}
|
}
|
|
|
{
|
{
|
std::string StringHex = (yysemantic_stack_[(7) - (6)]);
|
std::string StringHex = (yysemantic_stack_[(7) - (6)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
|
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetDestinationAddress( TempRegIndex );
|
I.SetImm( ImmediateValue );
|
I.SetImm( ImmediateValue );
|
I.SetDestZero(true);
|
I.SetDestZero(true);
|
I.SetSrc0Displace(true);
|
I.SetSrc0Displace(true);
|
I.SetWriteChannel(ECHANNEL_Z);
|
I.SetWriteChannel(ECHANNEL_Z);
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mBisonFlagTrippleConstAssign = true;
|
I.mBisonFlagTrippleConstAssign = true;
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
gInsertedInstructions++;
|
gInsertedInstructions++;
|
I.Clear();
|
I.Clear();
|
}
|
}
|
|
|
gExtraDestModifications = 2;
|
gExtraDestModifications = 2;
|
std::stringstream ss2;
|
std::stringstream ss2;
|
ss2 << "R" << TempRegIndex << " OFFSET ";
|
ss2 << "R" << TempRegIndex << " OFFSET ";
|
(yyval) = ss2.str();
|
(yyval) = ss2.str();
|
}
|
}
|
break;
|
break;
|
|
|
case 45:
|
case 46:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1898 "parser.y"
|
#line 2012 "parser.y"
|
{
|
{
|
|
|
|
|
std::string Register;
|
std::string Register;
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(2) - (1)]))) != "NULL")
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(2) - (1)]))) != "NULL")
|
(yyval) = Register;
|
(yyval) = Register;
|
else
|
else
|
(yyval) = GetRegisterFromAutoVar( (yysemantic_stack_[(2) - (1)]), yylloc) + " OFFSET ";
|
(yyval) = GetRegisterFromAutoVar( (yysemantic_stack_[(2) - (1)]), yylloc) + " OFFSET ";
|
|
|
if ((yysemantic_stack_[(2) - (2)]) != "NULL")
|
if ((yysemantic_stack_[(2) - (2)]) != "NULL")
|
{
|
{
|
|
|
(yyval) += " array_element " + (yysemantic_stack_[(2) - (2)]);
|
(yyval) += " array_element " + (yysemantic_stack_[(2) - (2)]);
|
|
|
}
|
}
|
}
|
}
|
break;
|
break;
|
|
|
case 46:
|
case 47:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1916 "parser.y"
|
#line 2030 "parser.y"
|
{
|
{
|
|
|
std::string X = (yysemantic_stack_[(5) - (3)]),Y = (yysemantic_stack_[(5) - (4)]),Z = (yysemantic_stack_[(5) - (5)]);
|
std::string X = (yysemantic_stack_[(5) - (3)]),Y = (yysemantic_stack_[(5) - (4)]),Z = (yysemantic_stack_[(5) - (5)]);
|
std::string Register;
|
std::string Register;
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(5) - (1)]))) != "NULL")
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(5) - (1)]))) != "NULL")
|
(yyval) = (Register + " . " + " " + X + " " + Y + " " + Z + " OFFSET ");
|
(yyval) = (Register + " . " + " " + X + " " + Y + " " + Z/* + " OFFSET "*/);
|
else
|
else
|
(yyval) = (GetRegisterFromAutoVar( (yysemantic_stack_[(5) - (1)]), yylloc) + " . " + " " + X + " " + Y + " " + Z + " OFFSET ");
|
(yyval) = (GetRegisterFromAutoVar( (yysemantic_stack_[(5) - (1)]), yylloc) + " . " + " " + X + " " + Y + " " + Z + " OFFSET ");
|
}
|
}
|
break;
|
break;
|
|
|
case 47:
|
case 48:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1927 "parser.y"
|
#line 2041 "parser.y"
|
{
|
{
|
|
|
std::string R = (yysemantic_stack_[(1) - (1)]);
|
std::string R = (yysemantic_stack_[(1) - (1)]);
|
R.erase(0,1);
|
R.erase(0,1);
|
(yyval) = "R" + R;
|
(yyval) = "R" + R;
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 48:
|
case 49:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1936 "parser.y"
|
#line 2050 "parser.y"
|
{
|
{
|
|
|
std::string R = (yysemantic_stack_[(4) - (1)]);
|
std::string R = (yysemantic_stack_[(4) - (1)]);
|
R.erase(0,1);
|
R.erase(0,1);
|
(yyval) = "<<R" + R;
|
(yyval) = "<<R" + R;
|
}
|
}
|
break;
|
break;
|
|
|
case 49:
|
case 50:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1944 "parser.y"
|
#line 2058 "parser.y"
|
{
|
{
|
|
|
std::string R = (yysemantic_stack_[(4) - (1)]);
|
std::string R = (yysemantic_stack_[(4) - (1)]);
|
R.erase(0,1);
|
R.erase(0,1);
|
(yyval) = ">>R" + R;
|
(yyval) = ">>R" + R;
|
}
|
}
|
break;
|
break;
|
|
|
case 50:
|
case 51:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1952 "parser.y"
|
#line 2066 "parser.y"
|
{
|
{
|
std::string R = (yysemantic_stack_[(5) - (1)]);
|
std::string R = (yysemantic_stack_[(5) - (1)]);
|
std::string X = (yysemantic_stack_[(5) - (3)]),Y = (yysemantic_stack_[(5) - (4)]),Z = (yysemantic_stack_[(5) - (5)]);
|
std::string X = (yysemantic_stack_[(5) - (3)]),Y = (yysemantic_stack_[(5) - (4)]),Z = (yysemantic_stack_[(5) - (5)]);
|
R.erase(0,1);
|
R.erase(0,1);
|
(yyval) = "R" + R + " . " + " " + X + " " + Y + " " + Z;
|
(yyval) = "R" + R + " . " + " " + X + " " + Y + " " + Z;
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 51:
|
case 52:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1965 "parser.y"
|
#line 2079 "parser.y"
|
{
|
{
|
(yyval) = "X";
|
(yyval) = "X";
|
}
|
}
|
break;
|
break;
|
|
|
case 52:
|
case 53:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1970 "parser.y"
|
#line 2084 "parser.y"
|
{
|
{
|
(yyval) = "-X";
|
(yyval) = "-X";
|
}
|
}
|
break;
|
break;
|
|
|
case 53:
|
case 54:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1975 "parser.y"
|
#line 2089 "parser.y"
|
{
|
{
|
(yyval) = "Y";
|
(yyval) = "Y";
|
}
|
}
|
break;
|
break;
|
|
|
case 54:
|
case 55:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1980 "parser.y"
|
#line 2094 "parser.y"
|
{
|
{
|
(yyval) = "-Y";
|
(yyval) = "-Y";
|
}
|
}
|
break;
|
break;
|
|
|
case 55:
|
case 56:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1985 "parser.y"
|
#line 2099 "parser.y"
|
{
|
{
|
(yyval) = "Z";
|
(yyval) = "Z";
|
}
|
}
|
break;
|
break;
|
|
|
case 56:
|
case 57:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1990 "parser.y"
|
#line 2104 "parser.y"
|
{
|
{
|
(yyval) = "-Z";
|
(yyval) = "-Z";
|
}
|
}
|
break;
|
break;
|
|
|
case 57:
|
case 58:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 1998 "parser.y"
|
#line 2112 "parser.y"
|
{
|
{
|
(yyval) = "NULL";
|
(yyval) = "NULL";
|
}
|
}
|
break;
|
break;
|
|
|
case 58:
|
case 59:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2003 "parser.y"
|
#line 2117 "parser.y"
|
{
|
{
|
/*std::string Register;
|
/*std::string Register;
|
if ((Register = GetRegisterFromFunctionParameter($2)) != "NULL")
|
if ((Register = GetRegisterFromFunctionParameter($2)) != "NULL")
|
$$ = Register;
|
$$ = Register;
|
else*/
|
else*/
|
//Indexes into arrays can only be auto variables!
|
//Indexes into arrays can only be auto variables!
|
(yyval) = GetRegisterFromAutoVar( (yysemantic_stack_[(3) - (2)]), yylloc );
|
(yyval) = GetRegisterFromAutoVar( (yysemantic_stack_[(3) - (2)]), yylloc );
|
}
|
}
|
break;
|
break;
|
|
|
case 59:
|
case 60:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2016 "parser.y"
|
#line 2130 "parser.y"
|
{
|
{
|
|
|
(yyval) = "OUT " + (yysemantic_stack_[(4) - (3)]);
|
(yyval) = "OUT " + (yysemantic_stack_[(4) - (3)]);
|
}
|
}
|
break;
|
break;
|
|
|
case 60:
|
case 61:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2022 "parser.y"
|
#line 2136 "parser.y"
|
{
|
{
|
std::string Register;
|
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(4) - (3)]))) == "NULL")
|
|
Register = GetRegisterFromAutoVar( (yysemantic_stack_[(4) - (3)]), yylloc );
|
|
|
|
|
std::string Register;
|
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(4) - (3)]))) != "NULL")
|
(yyval) = "OUT INDEX" + Register;
|
(yyval) = "OUT INDEX" + Register;
|
|
else
|
|
(yyval) = "OUT INDEX" + GetRegisterFromAutoVar( (yysemantic_stack_[(4) - (3)]), yylloc ) + " OFFSET ";
|
|
|
|
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 61:
|
case 62:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2031 "parser.y"
|
#line 2149 "parser.y"
|
{
|
{
|
|
|
std::string Register;
|
std::string Register;
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(2) - (1)]))) != "NULL")
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(2) - (1)]))) != "NULL")
|
(yyval) = Register + ".xyz";
|
(yyval) = Register + ".xyz";
|
else
|
else
|
(yyval) = GetRegisterFromAutoVar( (yysemantic_stack_[(2) - (1)]), yylloc ) + ".xyz" + " OFFSET " + (((yysemantic_stack_[(2) - (2)]) != "NULL")?" INDEX"+(yysemantic_stack_[(2) - (2)]):"");
|
(yyval) = GetRegisterFromAutoVar( (yysemantic_stack_[(2) - (1)]), yylloc ) + ".xyz" + " OFFSET " + (((yysemantic_stack_[(2) - (2)]) != "NULL")?" INDEX"+(yysemantic_stack_[(2) - (2)]):"");
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 62:
|
case 63:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2042 "parser.y"
|
#line 2160 "parser.y"
|
{
|
{
|
std::string Register;
|
std::string Register;
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(3) - (1)]))) != "NULL")
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(3) - (1)]))) != "NULL")
|
(yyval) = Register + ".x";
|
(yyval) = Register + ".x";
|
else
|
else
|
(yyval) = GetRegisterFromAutoVar( (yysemantic_stack_[(3) - (1)]), yylloc ) + ".x" + " OFFSET ";
|
(yyval) = GetRegisterFromAutoVar( (yysemantic_stack_[(3) - (1)]), yylloc ) + ".x" + " OFFSET ";
|
}
|
}
|
break;
|
break;
|
|
|
case 63:
|
case 64:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2051 "parser.y"
|
#line 2169 "parser.y"
|
{
|
{
|
std::string Register;
|
std::string Register;
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(3) - (1)]))) != "NULL")
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(3) - (1)]))) != "NULL")
|
(yyval) = Register + ".y";
|
(yyval) = Register + ".y";
|
else
|
else
|
(yyval) = GetRegisterFromAutoVar( (yysemantic_stack_[(3) - (1)]), yylloc ) + ".y" + " OFFSET ";
|
(yyval) = GetRegisterFromAutoVar( (yysemantic_stack_[(3) - (1)]), yylloc ) + ".y" + " OFFSET ";
|
}
|
}
|
break;
|
break;
|
|
|
case 64:
|
case 65:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2060 "parser.y"
|
#line 2178 "parser.y"
|
{
|
{
|
std::string Register;
|
std::string Register;
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(3) - (1)]))) != "NULL")
|
if ((Register = GetRegisterFromFunctionParameter((yysemantic_stack_[(3) - (1)]))) != "NULL")
|
(yyval) = Register + ".z";
|
(yyval) = Register + ".z";
|
else
|
else
|
(yyval) = GetRegisterFromAutoVar( (yysemantic_stack_[(3) - (1)]), yylloc ) + ".z" + " OFFSET ";
|
(yyval) = GetRegisterFromAutoVar( (yysemantic_stack_[(3) - (1)]), yylloc ) + ".z" + " OFFSET ";
|
}
|
}
|
break;
|
break;
|
|
|
case 65:
|
case 66:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2069 "parser.y"
|
#line 2187 "parser.y"
|
{
|
{
|
std::string R = (yysemantic_stack_[(1) - (1)]);
|
std::string R = (yysemantic_stack_[(1) - (1)]);
|
R.erase(0,1);
|
R.erase(0,1);
|
(yyval) = "R" + R + ".xyz";
|
(yyval) = "R" + R + ".xyz";
|
}
|
}
|
break;
|
break;
|
|
|
case 66:
|
case 67:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2076 "parser.y"
|
#line 2194 "parser.y"
|
{
|
{
|
std::string R = (yysemantic_stack_[(3) - (1)]);
|
std::string R = (yysemantic_stack_[(3) - (1)]);
|
R.erase(0,1);
|
R.erase(0,1);
|
(yyval) = "R" + R + ".x";
|
(yyval) = "R" + R + ".x";
|
}
|
}
|
break;
|
break;
|
|
|
case 67:
|
case 68:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2083 "parser.y"
|
#line 2201 "parser.y"
|
{
|
{
|
std::string R = (yysemantic_stack_[(3) - (1)]);
|
std::string R = (yysemantic_stack_[(3) - (1)]);
|
R.erase(0,1);
|
R.erase(0,1);
|
(yyval) = "R" + R + ".y";
|
(yyval) = "R" + R + ".y";
|
}
|
}
|
break;
|
break;
|
|
|
case 68:
|
case 69:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2090 "parser.y"
|
#line 2208 "parser.y"
|
{
|
{
|
|
|
std::string R = (yysemantic_stack_[(3) - (1)]);
|
std::string R = (yysemantic_stack_[(3) - (1)]);
|
R.erase(0,1);
|
R.erase(0,1);
|
(yyval) = "R" + R + ".z";
|
(yyval) = "R" + R + ".z";
|
}
|
}
|
break;
|
break;
|
|
|
case 69:
|
case 70:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2098 "parser.y"
|
#line 2216 "parser.y"
|
{
|
{
|
std::string R = (yysemantic_stack_[(5) - (1)]);
|
std::string R = (yysemantic_stack_[(5) - (1)]);
|
R.erase(0,1);
|
R.erase(0,1);
|
(yyval) = "R" + R + ".xy";
|
(yyval) = "R" + R + ".xy";
|
}
|
}
|
break;
|
break;
|
|
|
case 70:
|
case 71:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2105 "parser.y"
|
#line 2223 "parser.y"
|
{
|
{
|
std::string R = (yysemantic_stack_[(5) - (1)]);
|
std::string R = (yysemantic_stack_[(5) - (1)]);
|
R.erase(0,1);
|
R.erase(0,1);
|
(yyval) = "R" + R + ".xz";
|
(yyval) = "R" + R + ".xz";
|
}
|
}
|
break;
|
break;
|
|
|
case 71:
|
case 72:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2112 "parser.y"
|
#line 2230 "parser.y"
|
{
|
{
|
std::string R = (yysemantic_stack_[(5) - (1)]);
|
std::string R = (yysemantic_stack_[(5) - (1)]);
|
R.erase(0,1);
|
R.erase(0,1);
|
(yyval) = "R" + R + ".yz";
|
(yyval) = "R" + R + ".yz";
|
}
|
}
|
break;
|
break;
|
|
|
case 72:
|
case 73:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2123 "parser.y"
|
#line 2241 "parser.y"
|
{
|
{
|
PopulateBoolean(EBRANCH_IF_ZERO, (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions, yylloc );
|
PopulateBoolean(EBRANCH_IF_ZERO, (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions, yylloc );
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 73:
|
case 74:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2129 "parser.y"
|
#line 2247 "parser.y"
|
{
|
{
|
PopulateBoolean(EBRANCH_IF_NOT_ZERO, (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions, yylloc );
|
PopulateBoolean(EBRANCH_IF_NOT_ZERO, (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions, yylloc );
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 74:
|
case 75:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2135 "parser.y"
|
#line 2253 "parser.y"
|
{
|
{
|
PopulateBoolean(EBRANCH_IF_ZERO_OR_SIGN, (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions, yylloc );
|
PopulateBoolean(EBRANCH_IF_ZERO_OR_SIGN, (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions, yylloc );
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 75:
|
case 76:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2142 "parser.y"
|
#line 2260 "parser.y"
|
{
|
{
|
PopulateBoolean(EBRANCH_IF_ZERO_OR_NOT_SIGN, (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions, yylloc );
|
PopulateBoolean(EBRANCH_IF_ZERO_OR_NOT_SIGN, (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions, yylloc );
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 76:
|
case 77:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2148 "parser.y"
|
#line 2266 "parser.y"
|
{
|
{
|
PopulateBoolean(EBRANCH_IF_NOT_SIGN, (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions, yylloc );
|
PopulateBoolean(EBRANCH_IF_NOT_SIGN, (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions, yylloc );
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 77:
|
case 78:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2154 "parser.y"
|
#line 2272 "parser.y"
|
{
|
{
|
PopulateBoolean(EBRANCH_IF_SIGN, (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions, yylloc );
|
PopulateBoolean(EBRANCH_IF_SIGN, (yysemantic_stack_[(3) - (1)]), (yysemantic_stack_[(3) - (3)]), I, mInstructions, yylloc );
|
|
|
}
|
}
|
break;
|
break;
|
|
|
case 78:
|
case 79:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2163 "parser.y"
|
#line 2281 "parser.y"
|
{
|
{
|
// Transform to HEX string
|
// Transform to HEX string
|
unsigned int Val;
|
unsigned int Val;
|
std::string StringDec = (yysemantic_stack_[(1) - (1)]);
|
std::string StringDec = (yysemantic_stack_[(1) - (1)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << StringDec;
|
ss << StringDec;
|
ss >> Val;
|
ss >> Val;
|
std::stringstream ss2;
|
std::stringstream ss2;
|
ss2 << std::hex << Val;
|
ss2 << std::hex << Val;
|
(yyval) = ss2.str();
|
(yyval) = ss2.str();
|
}
|
}
|
break;
|
break;
|
|
|
case 79:
|
case 80:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2176 "parser.y"
|
#line 2294 "parser.y"
|
{
|
{
|
std::string StringHex = (yysemantic_stack_[(1) - (1)]);
|
std::string StringHex = (yysemantic_stack_[(1) - (1)]);
|
// Get rid of the 0x
|
// Get rid of the 0x
|
StringHex.erase(StringHex.begin(),StringHex.begin()+2);
|
StringHex.erase(StringHex.begin(),StringHex.begin()+2);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
|
|
(yyval) = ss.str();
|
(yyval) = ss.str();
|
}
|
}
|
break;
|
break;
|
|
|
case 80:
|
case 81:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2187 "parser.y"
|
#line 2305 "parser.y"
|
{
|
{
|
// Transform to HEX string
|
// Transform to HEX string
|
std::string StringBin = (yysemantic_stack_[(1) - (1)]);
|
std::string StringBin = (yysemantic_stack_[(1) - (1)]);
|
// Get rid of the 0b
|
// Get rid of the 0b
|
StringBin.erase(StringBin.begin(),StringBin.begin()+2);
|
StringBin.erase(StringBin.begin(),StringBin.begin()+2);
|
std::bitset<32> Bitset( StringBin );
|
std::bitset<32> Bitset( StringBin );
|
std::stringstream ss2;
|
std::stringstream ss2;
|
ss2 << std::hex << Bitset.to_ulong();
|
ss2 << std::hex << Bitset.to_ulong();
|
(yyval) = ss2.str();
|
(yyval) = ss2.str();
|
}
|
}
|
break;
|
break;
|
|
|
case 81:
|
case 82:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2201 "parser.y"
|
#line 2319 "parser.y"
|
{
|
{
|
if (gAutoVarMap.find((yysemantic_stack_[(4) - (1)])) != gAutoVarMap.end())
|
if (gAutoVarMap.find((yysemantic_stack_[(4) - (1)])) != gAutoVarMap.end())
|
{
|
{
|
std::ostringstream ret;
|
std::ostringstream ret;
|
ret << "Duplicated symbol '" << (yysemantic_stack_[(4) - (1)]) << "'\n";
|
ret << "Duplicated symbol '" << (yysemantic_stack_[(4) - (1)]) << "'\n";
|
throw ret.str();
|
throw ret.str();
|
}
|
}
|
|
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << (yysemantic_stack_[(4) - (2)]);
|
ss << (yysemantic_stack_[(4) - (2)]);
|
unsigned int Size;
|
unsigned int Size;
|
ss >> Size;
|
ss >> Size;
|
gAutoVarMap[ (yysemantic_stack_[(4) - (1)]) ] = AllocAutoVar(Size);
|
gAutoVarMap[ (yysemantic_stack_[(4) - (1)]) ] = AllocAutoVar(Size);
|
}
|
}
|
break;
|
break;
|
|
|
case 82:
|
case 83:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2217 "parser.y"
|
#line 2335 "parser.y"
|
{
|
{
|
if (gAutoVarMap.find((yysemantic_stack_[(11) - (1)])) != gAutoVarMap.end())
|
if (gAutoVarMap.find((yysemantic_stack_[(11) - (1)])) != gAutoVarMap.end())
|
{
|
{
|
std::ostringstream ret;
|
std::ostringstream ret;
|
ret << "Duplicated symbol " << (yysemantic_stack_[(11) - (1)]) << "'\n";
|
ret << "Duplicated symbol " << (yysemantic_stack_[(11) - (1)]) << "'\n";
|
throw ret.str();
|
throw ret.str();
|
}
|
}
|
gAutoVarMap[ (yysemantic_stack_[(11) - (1)]) ] = AllocAutoVar();
|
gAutoVarMap[ (yysemantic_stack_[(11) - (1)]) ] = AllocAutoVar();
|
|
|
unsigned int Destination = gAutoVarMap[ (yysemantic_stack_[(11) - (1)]) ];
|
unsigned int Destination = gAutoVarMap[ (yysemantic_stack_[(11) - (1)]) ];
|
|
|
|
|
|
|
I.ClearWriteChannel();
|
I.ClearWriteChannel();
|
unsigned int ImmediateValue;
|
unsigned int ImmediateValue;
|
{
|
{
|
I.SetDestinationAddress( Destination );
|
I.SetDestinationAddress( Destination );
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
std::string StringHex = (yysemantic_stack_[(11) - (4)]);
|
std::string StringHex = (yysemantic_stack_[(11) - (4)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
I.SetImm( ImmediateValue );
|
I.SetImm( ImmediateValue );
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.SetSrc1Displace( false );
|
I.SetSrc1Displace( false );
|
I.SetSrc0Displace( true );
|
I.SetSrc0Displace( true );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
}
|
}
|
{
|
{
|
I.SetDestinationAddress( Destination );
|
I.SetDestinationAddress( Destination );
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetWriteChannel(ECHANNEL_Y);
|
std::string StringHex = (yysemantic_stack_[(11) - (6)]);
|
std::string StringHex = (yysemantic_stack_[(11) - (6)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
I.SetImm( ImmediateValue );
|
I.SetImm( ImmediateValue );
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.SetSrc1Displace( false );
|
I.SetSrc1Displace( false );
|
I.SetSrc0Displace( true );
|
I.SetSrc0Displace( true );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
}
|
}
|
{
|
{
|
I.SetDestinationAddress( Destination );
|
I.SetDestinationAddress( Destination );
|
I.SetWriteChannel(ECHANNEL_Z);
|
I.SetWriteChannel(ECHANNEL_Z);
|
std::string StringHex = (yysemantic_stack_[(11) - (8)]);
|
std::string StringHex = (yysemantic_stack_[(11) - (8)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
I.SetImm( ImmediateValue );
|
I.SetImm( ImmediateValue );
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.SetSrc1Displace( false );
|
I.SetSrc1Displace( false );
|
I.SetSrc0Displace( true );
|
I.SetSrc0Displace( true );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
}
|
}
|
}
|
}
|
break;
|
break;
|
|
|
case 83:
|
case 84:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2281 "parser.y"
|
#line 2399 "parser.y"
|
{
|
{
|
if (gAutoVarMap.find((yysemantic_stack_[(9) - (1)])) != gAutoVarMap.end())
|
if (gAutoVarMap.find((yysemantic_stack_[(9) - (1)])) != gAutoVarMap.end())
|
{
|
{
|
std::ostringstream ret;
|
std::ostringstream ret;
|
ret << "Duplicated symbol " << (yysemantic_stack_[(9) - (1)]) << "'\n";
|
ret << "Duplicated symbol " << (yysemantic_stack_[(9) - (1)]) << "'\n";
|
throw ret.str();
|
throw ret.str();
|
}
|
}
|
gAutoVarMap[ (yysemantic_stack_[(9) - (1)]) ] = AllocAutoVar();
|
gAutoVarMap[ (yysemantic_stack_[(9) - (1)]) ] = AllocAutoVar();
|
|
|
unsigned int Destination = gAutoVarMap[ (yysemantic_stack_[(9) - (1)]) ];
|
unsigned int Destination = gAutoVarMap[ (yysemantic_stack_[(9) - (1)]) ];
|
|
|
|
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.SetSrc1Displace( false );
|
I.SetSrc1Displace( false );
|
I.SetSrc0Displace( true );
|
I.SetSrc0Displace( true );
|
|
|
|
|
I.ClearWriteChannel();
|
I.ClearWriteChannel();
|
unsigned int ImmediateValue;
|
unsigned int ImmediateValue;
|
{
|
{
|
I.SetDestinationAddress( Destination );
|
I.SetDestinationAddress( Destination );
|
I.SetWriteChannel(ECHANNEL_X);
|
I.SetWriteChannel(ECHANNEL_X);
|
std::string StringHex = (yysemantic_stack_[(9) - (4)]);
|
std::string StringHex = (yysemantic_stack_[(9) - (4)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
I.SetImm( ImmediateValue );
|
I.SetImm( ImmediateValue );
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.SetSrc1Displace( false );
|
I.SetSrc1Displace( false );
|
I.SetSrc0Displace( true );
|
I.SetSrc0Displace( true );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
I.mSourceLine = GetCurrentLineNumber( yylloc );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
}
|
}
|
{
|
{
|
I.SetDestinationAddress( Destination );
|
I.SetDestinationAddress( Destination );
|
I.SetWriteChannel(ECHANNEL_Y);
|
I.SetWriteChannel(ECHANNEL_Y);
|
std::string StringHex = (yysemantic_stack_[(9) - (6)]);
|
std::string StringHex = (yysemantic_stack_[(9) - (6)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
I.SetImm( ImmediateValue );
|
I.SetImm( ImmediateValue );
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.SetSrc1Displace( false );
|
I.SetSrc1Displace( false );
|
I.SetSrc0Displace( true );
|
I.SetSrc0Displace( true );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
}
|
}
|
{
|
{
|
I.SetDestinationAddress( Destination );
|
I.SetDestinationAddress( Destination );
|
I.SetWriteChannel(ECHANNEL_Z);
|
I.SetWriteChannel(ECHANNEL_Z);
|
std::string StringHex = (yysemantic_stack_[(9) - (8)]);
|
std::string StringHex = (yysemantic_stack_[(9) - (8)]);
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << StringHex;
|
ss << std::hex << StringHex;
|
ss >> ImmediateValue;
|
ss >> ImmediateValue;
|
I.SetImm( ImmediateValue );
|
I.SetImm( ImmediateValue );
|
I.SetDestZero( true );
|
I.SetDestZero( true );
|
I.SetSrc1Displace( false );
|
I.SetSrc1Displace( false );
|
I.SetSrc0Displace( true );
|
I.SetSrc0Displace( true );
|
I.SetCode( EOPERATION_ADD );
|
I.SetCode( EOPERATION_ADD );
|
mInstructions.push_back(I);
|
mInstructions.push_back(I);
|
I.Clear();
|
I.Clear();
|
}
|
}
|
}
|
}
|
break;
|
break;
|
|
|
case 84:
|
case 85:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2349 "parser.y"
|
#line 2467 "parser.y"
|
{
|
{
|
|
|
if (gAutoVarMap.find((yysemantic_stack_[(2) - (1)])) != gAutoVarMap.end())
|
if (gAutoVarMap.find((yysemantic_stack_[(2) - (1)])) != gAutoVarMap.end())
|
{
|
{
|
std::ostringstream ret;
|
std::ostringstream ret;
|
ret << "Duplicated symbol " << (yysemantic_stack_[(2) - (1)]) << "'\n";
|
ret << "Duplicated symbol " << (yysemantic_stack_[(2) - (1)]) << "'\n";
|
throw ret.str();
|
throw ret.str();
|
}
|
}
|
std::stringstream ss;
|
std::stringstream ss;
|
ss << std::hex << (yysemantic_stack_[(2) - (2)]);
|
ss << std::hex << (yysemantic_stack_[(2) - (2)]);
|
unsigned int Size;
|
unsigned int Size;
|
ss >> Size;
|
ss >> Size;
|
////std::cout << "Array Size is " << Size << " " << $2 << "\n";
|
////std::cout << "Array Size is " << Size << " " << $2 << "\n";
|
gAutoVarMap[ (yysemantic_stack_[(2) - (1)]) ] = AllocAutoVar(Size);
|
gAutoVarMap[ (yysemantic_stack_[(2) - (1)]) ] = AllocAutoVar(Size);
|
}
|
}
|
break;
|
break;
|
|
|
case 85:
|
case 86:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2368 "parser.y"
|
#line 2486 "parser.y"
|
{
|
{
|
(yyval) = "1";
|
(yyval) = "1";
|
}
|
}
|
break;
|
break;
|
|
|
case 86:
|
case 87:
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2373 "parser.y"
|
#line 2491 "parser.y"
|
{
|
{
|
|
|
(yyval) = (yysemantic_stack_[(3) - (2)]);
|
(yyval) = (yysemantic_stack_[(3) - (2)]);
|
}
|
}
|
break;
|
break;
|
|
|
|
|
|
|
/* Line 678 of lalr1.cc */
|
/* Line 678 of lalr1.cc */
|
#line 2972 "parser.tab.c"
|
#line 3006 "parser.tab.c"
|
default:
|
default:
|
break;
|
break;
|
}
|
}
|
YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
|
YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
|
|
|
yypop_ (yylen);
|
yypop_ (yylen);
|
yylen = 0;
|
yylen = 0;
|
YY_STACK_PRINT ();
|
YY_STACK_PRINT ();
|
|
|
yysemantic_stack_.push (yyval);
|
yysemantic_stack_.push (yyval);
|
yylocation_stack_.push (yyloc);
|
yylocation_stack_.push (yyloc);
|
|
|
/* Shift the result of the reduction. */
|
/* Shift the result of the reduction. */
|
yyn = yyr1_[yyn];
|
yyn = yyr1_[yyn];
|
yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
|
yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
|
if (0 <= yystate && yystate <= yylast_
|
if (0 <= yystate && yystate <= yylast_
|
&& yycheck_[yystate] == yystate_stack_[0])
|
&& yycheck_[yystate] == yystate_stack_[0])
|
yystate = yytable_[yystate];
|
yystate = yytable_[yystate];
|
else
|
else
|
yystate = yydefgoto_[yyn - yyntokens_];
|
yystate = yydefgoto_[yyn - yyntokens_];
|
goto yynewstate;
|
goto yynewstate;
|
|
|
/*------------------------------------.
|
/*------------------------------------.
|
| yyerrlab -- here on detecting error |
|
| yyerrlab -- here on detecting error |
|
`------------------------------------*/
|
`------------------------------------*/
|
yyerrlab:
|
yyerrlab:
|
/* If not already recovering from an error, report this error. */
|
/* If not already recovering from an error, report this error. */
|
if (!yyerrstatus_)
|
if (!yyerrstatus_)
|
{
|
{
|
++yynerrs_;
|
++yynerrs_;
|
error (yylloc, yysyntax_error_ (yystate, yytoken));
|
error (yylloc, yysyntax_error_ (yystate, yytoken));
|
}
|
}
|
|
|
yyerror_range[0] = yylloc;
|
yyerror_range[0] = yylloc;
|
if (yyerrstatus_ == 3)
|
if (yyerrstatus_ == 3)
|
{
|
{
|
/* If just tried and failed to reuse lookahead token after an
|
/* If just tried and failed to reuse lookahead token after an
|
error, discard it. */
|
error, discard it. */
|
|
|
if (yychar <= yyeof_)
|
if (yychar <= yyeof_)
|
{
|
{
|
/* Return failure if at end of input. */
|
/* Return failure if at end of input. */
|
if (yychar == yyeof_)
|
if (yychar == yyeof_)
|
YYABORT;
|
YYABORT;
|
}
|
}
|
else
|
else
|
{
|
{
|
yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
|
yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
|
yychar = yyempty_;
|
yychar = yyempty_;
|
}
|
}
|
}
|
}
|
|
|
/* Else will try to reuse lookahead token after shifting the error
|
/* Else will try to reuse lookahead token after shifting the error
|
token. */
|
token. */
|
goto yyerrlab1;
|
goto yyerrlab1;
|
|
|
|
|
/*---------------------------------------------------.
|
/*---------------------------------------------------.
|
| yyerrorlab -- error raised explicitly by YYERROR. |
|
| yyerrorlab -- error raised explicitly by YYERROR. |
|
`---------------------------------------------------*/
|
`---------------------------------------------------*/
|
yyerrorlab:
|
yyerrorlab:
|
|
|
/* Pacify compilers like GCC when the user code never invokes
|
/* Pacify compilers like GCC when the user code never invokes
|
YYERROR and the label yyerrorlab therefore never appears in user
|
YYERROR and the label yyerrorlab therefore never appears in user
|
code. */
|
code. */
|
if (false)
|
if (false)
|
goto yyerrorlab;
|
goto yyerrorlab;
|
|
|
yyerror_range[0] = yylocation_stack_[yylen - 1];
|
yyerror_range[0] = yylocation_stack_[yylen - 1];
|
/* Do not reclaim the symbols of the rule which action triggered
|
/* Do not reclaim the symbols of the rule which action triggered
|
this YYERROR. */
|
this YYERROR. */
|
yypop_ (yylen);
|
yypop_ (yylen);
|
yylen = 0;
|
yylen = 0;
|
yystate = yystate_stack_[0];
|
yystate = yystate_stack_[0];
|
goto yyerrlab1;
|
goto yyerrlab1;
|
|
|
/*-------------------------------------------------------------.
|
/*-------------------------------------------------------------.
|
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
`-------------------------------------------------------------*/
|
`-------------------------------------------------------------*/
|
yyerrlab1:
|
yyerrlab1:
|
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
|
|
for (;;)
|
for (;;)
|
{
|
{
|
yyn = yypact_[yystate];
|
yyn = yypact_[yystate];
|
if (yyn != yypact_ninf_)
|
if (yyn != yypact_ninf_)
|
{
|
{
|
yyn += yyterror_;
|
yyn += yyterror_;
|
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
{
|
{
|
yyn = yytable_[yyn];
|
yyn = yytable_[yyn];
|
if (0 < yyn)
|
if (0 < yyn)
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
/* Pop the current state because it cannot handle the error token. */
|
/* Pop the current state because it cannot handle the error token. */
|
if (yystate_stack_.height () == 1)
|
if (yystate_stack_.height () == 1)
|
YYABORT;
|
YYABORT;
|
|
|
yyerror_range[0] = yylocation_stack_[0];
|
yyerror_range[0] = yylocation_stack_[0];
|
yydestruct_ ("Error: popping",
|
yydestruct_ ("Error: popping",
|
yystos_[yystate],
|
yystos_[yystate],
|
&yysemantic_stack_[0], &yylocation_stack_[0]);
|
&yysemantic_stack_[0], &yylocation_stack_[0]);
|
yypop_ ();
|
yypop_ ();
|
yystate = yystate_stack_[0];
|
yystate = yystate_stack_[0];
|
YY_STACK_PRINT ();
|
YY_STACK_PRINT ();
|
}
|
}
|
|
|
yyerror_range[1] = yylloc;
|
yyerror_range[1] = yylloc;
|
// Using YYLLOC is tempting, but would change the location of
|
// Using YYLLOC is tempting, but would change the location of
|
// the lookahead. YYLOC is available though.
|
// the lookahead. YYLOC is available though.
|
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
|
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
|
yysemantic_stack_.push (yylval);
|
yysemantic_stack_.push (yylval);
|
yylocation_stack_.push (yyloc);
|
yylocation_stack_.push (yyloc);
|
|
|
/* Shift the error token. */
|
/* Shift the error token. */
|
YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
|
YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
|
&yysemantic_stack_[0], &yylocation_stack_[0]);
|
&yysemantic_stack_[0], &yylocation_stack_[0]);
|
|
|
yystate = yyn;
|
yystate = yyn;
|
goto yynewstate;
|
goto yynewstate;
|
|
|
/* Accept. */
|
/* Accept. */
|
yyacceptlab:
|
yyacceptlab:
|
yyresult = 0;
|
yyresult = 0;
|
goto yyreturn;
|
goto yyreturn;
|
|
|
/* Abort. */
|
/* Abort. */
|
yyabortlab:
|
yyabortlab:
|
yyresult = 1;
|
yyresult = 1;
|
goto yyreturn;
|
goto yyreturn;
|
|
|
yyreturn:
|
yyreturn:
|
if (yychar != yyempty_)
|
if (yychar != yyempty_)
|
yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
|
yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
|
|
|
/* Do not reclaim the symbols of the rule which action triggered
|
/* Do not reclaim the symbols of the rule which action triggered
|
this YYABORT or YYACCEPT. */
|
this YYABORT or YYACCEPT. */
|
yypop_ (yylen);
|
yypop_ (yylen);
|
while (yystate_stack_.height () != 1)
|
while (yystate_stack_.height () != 1)
|
{
|
{
|
yydestruct_ ("Cleanup: popping",
|
yydestruct_ ("Cleanup: popping",
|
yystos_[yystate_stack_[0]],
|
yystos_[yystate_stack_[0]],
|
&yysemantic_stack_[0],
|
&yysemantic_stack_[0],
|
&yylocation_stack_[0]);
|
&yylocation_stack_[0]);
|
yypop_ ();
|
yypop_ ();
|
}
|
}
|
|
|
return yyresult;
|
return yyresult;
|
}
|
}
|
|
|
// Generate an error message.
|
// Generate an error message.
|
std::string
|
std::string
|
Parser::yysyntax_error_ (int yystate, int tok)
|
Parser::yysyntax_error_ (int yystate, int tok)
|
{
|
{
|
std::string res;
|
std::string res;
|
YYUSE (yystate);
|
YYUSE (yystate);
|
#if YYERROR_VERBOSE
|
#if YYERROR_VERBOSE
|
int yyn = yypact_[yystate];
|
int yyn = yypact_[yystate];
|
if (yypact_ninf_ < yyn && yyn <= yylast_)
|
if (yypact_ninf_ < yyn && yyn <= yylast_)
|
{
|
{
|
/* Start YYX at -YYN if negative to avoid negative indexes in
|
/* Start YYX at -YYN if negative to avoid negative indexes in
|
YYCHECK. */
|
YYCHECK. */
|
int yyxbegin = yyn < 0 ? -yyn : 0;
|
int yyxbegin = yyn < 0 ? -yyn : 0;
|
|
|
/* Stay within bounds of both yycheck and yytname. */
|
/* Stay within bounds of both yycheck and yytname. */
|
int yychecklim = yylast_ - yyn + 1;
|
int yychecklim = yylast_ - yyn + 1;
|
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
int count = 0;
|
int count = 0;
|
for (int x = yyxbegin; x < yyxend; ++x)
|
for (int x = yyxbegin; x < yyxend; ++x)
|
if (yycheck_[x + yyn] == x && x != yyterror_)
|
if (yycheck_[x + yyn] == x && x != yyterror_)
|
++count;
|
++count;
|
|
|
// FIXME: This method of building the message is not compatible
|
// FIXME: This method of building the message is not compatible
|
// with internationalization. It should work like yacc.c does it.
|
// with internationalization. It should work like yacc.c does it.
|
// That is, first build a string that looks like this:
|
// That is, first build a string that looks like this:
|
// "syntax error, unexpected %s or %s or %s"
|
// "syntax error, unexpected %s or %s or %s"
|
// Then, invoke YY_ on this string.
|
// Then, invoke YY_ on this string.
|
// Finally, use the string as a format to output
|
// Finally, use the string as a format to output
|
// yytname_[tok], etc.
|
// yytname_[tok], etc.
|
// Until this gets fixed, this message appears in English only.
|
// Until this gets fixed, this message appears in English only.
|
res = "syntax error, unexpected ";
|
res = "syntax error, unexpected ";
|
res += yytnamerr_ (yytname_[tok]);
|
res += yytnamerr_ (yytname_[tok]);
|
if (count < 5)
|
if (count < 5)
|
{
|
{
|
count = 0;
|
count = 0;
|
for (int x = yyxbegin; x < yyxend; ++x)
|
for (int x = yyxbegin; x < yyxend; ++x)
|
if (yycheck_[x + yyn] == x && x != yyterror_)
|
if (yycheck_[x + yyn] == x && x != yyterror_)
|
{
|
{
|
res += (!count++) ? ", expecting " : " or ";
|
res += (!count++) ? ", expecting " : " or ";
|
res += yytnamerr_ (yytname_[x]);
|
res += yytnamerr_ (yytname_[x]);
|
}
|
}
|
}
|
}
|
}
|
}
|
else
|
else
|
#endif
|
#endif
|
res = YY_("syntax error");
|
res = YY_("syntax error");
|
return res;
|
return res;
|
}
|
}
|
|
|
|
|
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
STATE-NUM. */
|
STATE-NUM. */
|
const signed char Parser::yypact_ninf_ = -121;
|
const signed char Parser::yypact_ninf_ = -126;
|
const short int
|
const short int
|
Parser::yypact_[] =
|
Parser::yypact_[] =
|
{
|
{
|
216, -26, 243, -19, -14, 3, 19, -11, 27, -121,
|
258, -21, 92, -15, -6, 24, 13, -9, 5, -126,
|
20, 33, 29, 7, -121, 50, 68, 45, 248, -121,
|
28, 43, 6, 8, -126, 126, -11, 44, 252, -126,
|
-121, -121, -121, 48, -22, 59, 71, 75, 54, 8,
|
-126, -126, -126, 55, -12, 74, 76, 77, 54, 110,
|
-121, -121, -121, 108, -121, 248, 184, 248, 153, 81,
|
-16, -126, -126, -126, 84, -126, 252, 188, 252, 157,
|
-121, 104, 117, 122, 126, 134, -121, -121, 271, 121,
|
68, -126, 85, 88, 98, 99, 138, -126, -126, 275,
|
123, 173, 135, 173, 114, -121, 15, 115, 195, 195,
|
109, 106, 177, 120, 177, 100, -126, 36, 101, 199,
|
-121, 248, 127, 133, 248, -121, 248, 248, 248, 248,
|
199, -126, 252, 113, 114, 118, 298, -126, 298, 298,
|
248, 138, 14, 157, 103, -121, -121, 148, 164, 100,
|
298, 298, 298, 121, 15, 127, 41, -126, -126, 134,
|
-121, -121, -121, 145, -121, 248, 174, 175, 151, 158,
|
128, 50, -126, -126, -126, 135, -126, 252, 160, 166,
|
24, 57, 182, 183, 185, 173, 179, -26, -121, 173,
|
142, 149, 18, 111, 168, 169, 171, 177, 162, -21,
|
205, -121, -121, -121, 195, 195, 16, 211, 212, 8,
|
-126, 177, 213, -126, -126, -126, 199, 199, 52, 196,
|
8, 8, -121, -121, -121, 190, 215, 248, 248, 248,
|
197, 173, -16, -16, -16, -126, -126, -126, 185, 215,
|
248, 248, 248, 224, 214, 220, 221, 217, 248, -121,
|
252, 252, 252, 252, 252, 252, 217, 200, 204, 208,
|
231, -121, 227, -121, -121, 248, -121, -121, -121, -121,
|
214, 252, -126, 229, -126, 221, -126, -126, 252, -126,
|
230, -121, -121, 234, -121, -121, -121, 195, 195, -121,
|
-126, -126, -126, 210, -126, -126, 211, -126, -126, -126,
|
-121, -121, 138, -121, 86, 86, 86, 86, 86, 86,
|
199, 199, -126, -126, -126, -126, 121, -126, 82, 82,
|
216, -121, -121, -121, -121, -121, 238, 239, -121, 241,
|
82, 82, 82, 82, 258, -126, -126, -126, -126, -126,
|
173, 173, -121, -121, -121, 247, 55, 216, 216, 249,
|
242, 251, -126, 254, 177, 177, -126, -126, -126, 255,
|
250, 244, 216, 273, 93, 143, -121, 173, -121, 161,
|
63, 258, 258, 247, 234, 262, 258, 265, 147, 165,
|
-121, -121, -121, 272, -121, 274, 252, 216, -26, 199,
|
-126, 177, -126, 203, -126, -126, -126, 264, -126, 266,
|
-121, -121
|
241, 258, -21, 220, -126, -126
|
};
|
};
|
|
|
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
|
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
|
doesn't specify something else to do. Zero means the default is an
|
doesn't specify something else to do. Zero means the default is an
|
error. */
|
error. */
|
const unsigned char
|
const unsigned char
|
Parser::yydefact_[] =
|
Parser::yydefact_[] =
|
{
|
{
|
2, 0, 0, 0, 0, 0, 65, 57, 0, 14,
|
2, 0, 0, 0, 0, 0, 66, 58, 0, 14,
|
0, 0, 0, 0, 4, 0, 85, 0, 0, 78,
|
0, 0, 0, 0, 4, 0, 86, 0, 0, 79,
|
79, 80, 9, 47, 57, 0, 0, 0, 0, 35,
|
80, 81, 9, 48, 58, 0, 0, 0, 0, 0,
|
39, 40, 43, 0, 7, 0, 0, 26, 0, 0,
|
36, 40, 41, 44, 0, 7, 0, 0, 26, 0,
|
61, 0, 0, 0, 0, 0, 1, 3, 0, 0,
|
0, 62, 0, 0, 0, 0, 0, 1, 3, 0,
|
0, 0, 0, 0, 84, 5, 0, 43, 0, 0,
|
0, 0, 0, 0, 0, 85, 5, 0, 44, 0,
|
45, 0, 0, 0, 0, 8, 0, 0, 0, 0,
|
0, 46, 0, 0, 0, 0, 0, 8, 0, 0,
|
0, 29, 0, 0, 66, 67, 68, 0, 0, 28,
|
0, 0, 0, 29, 0, 0, 67, 68, 69, 0,
|
62, 63, 64, 0, 6, 0, 0, 0, 0, 0,
|
0, 28, 63, 64, 65, 0, 6, 0, 0, 0,
|
57, 0, 0, 0, 0, 0, 0, 0, 42, 0,
|
0, 0, 58, 0, 0, 0, 0, 0, 0, 0,
|
0, 51, 53, 55, 0, 0, 0, 0, 0, 32,
|
43, 0, 0, 52, 54, 56, 0, 0, 0, 0,
|
33, 34, 37, 36, 38, 31, 0, 0, 0, 0,
|
0, 0, 32, 33, 34, 38, 37, 39, 31, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 26, 58,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 21, 0, 60, 59, 26, 13, 12, 11, 10,
|
0, 26, 59, 0, 21, 0, 61, 60, 26, 13,
|
0, 86, 81, 0, 52, 54, 56, 0, 0, 41,
|
12, 11, 10, 0, 87, 82, 0, 53, 55, 57,
|
48, 49, 29, 19, 73, 72, 74, 75, 76, 77,
|
0, 0, 42, 49, 50, 35, 29, 19, 74, 73,
|
2, 69, 70, 71, 25, 27, 0, 0, 23, 0,
|
75, 76, 77, 78, 2, 70, 71, 72, 25, 27,
|
0, 0, 50, 46, 30, 0, 0, 2, 2, 0,
|
0, 0, 23, 0, 0, 0, 51, 47, 30, 0,
|
0, 0, 2, 18, 0, 0, 24, 0, 44, 0,
|
0, 2, 2, 0, 0, 0, 2, 18, 0, 0,
|
16, 15, 22, 0, 20, 0, 83, 2, 0, 0,
|
24, 0, 45, 0, 16, 15, 22, 0, 20, 0,
|
82, 17
|
84, 2, 0, 0, 83, 17
|
};
|
};
|
|
|
/* YYPGOTO[NTERM-NUM]. */
|
/* YYPGOTO[NTERM-NUM]. */
|
const short int
|
const short int
|
Parser::yypgoto_[] =
|
Parser::yypgoto_[] =
|
{
|
{
|
-121, -52, -13, -121, -121, -121, -121, -120, 142, 0,
|
-126, -125, -13, -126, -126, -126, -126, -121, 129, 0,
|
47, 171, -121, -55, 283, -121, 213, -17, -94, -121
|
20, 186, -126, -56, 276, -126, 207, -17, -96, -126
|
};
|
};
|
|
|
/* YYDEFGOTO[NTERM-NUM]. */
|
/* YYDEFGOTO[NTERM-NUM]. */
|
const short int
|
const short int
|
Parser::yydefgoto_[] =
|
Parser::yydefgoto_[] =
|
{
|
{
|
-1, 13, 14, 42, 195, 175, 167, 78, 116, 79,
|
-1, 13, 14, 43, 199, 179, 171, 80, 119, 81,
|
29, 30, 31, 104, 60, 15, 73, 32, 17, 54
|
30, 31, 32, 106, 61, 15, 75, 33, 17, 55
|
};
|
};
|
|
|
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
positive, shift that token. If negative, reduce the rule which
|
positive, shift that token. If negative, reduce the rule which
|
number is the opposite. If zero, do what YYDEFACT says. */
|
number is the opposite. If zero, do what YYDEFACT says. */
|
const signed char Parser::yytable_ninf_ = -1;
|
const signed char Parser::yytable_ninf_ = -1;
|
const unsigned char
|
const unsigned char
|
Parser::yytable_[] =
|
Parser::yytable_[] =
|
{
|
{
|
47, 57, 28, 142, 105, 37, 59, 46, 165, 16,
|
48, 58, 29, 145, 107, 70, 71, 38, 47, 53,
|
1, 2, 3, 34, 4, 169, 33, 38, 56, 35,
|
169, 1, 2, 3, 16, 4, 60, 173, 57, 39,
|
39, 5, 117, 118, 119, 120, 121, 122, 89, 68,
|
34, 35, 5, 120, 121, 122, 123, 124, 125, 91,
|
69, 39, 98, 149, 94, 72, 96, 64, 64, 64,
|
40, 54, 72, 40, 138, 96, 74, 98, 66, 180,
|
135, 6, 7, 66, 66, 66, 8, 36, 91, 147,
|
36, 37, 6, 7, 68, 42, 60, 8, 46, 93,
|
148, 9, 59, 10, 11, 43, 70, 12, 1, 2,
|
150, 151, 9, 100, 10, 11, 188, 189, 12, 66,
|
3, 106, 4, 67, 67, 67, 39, 41, 44, 5,
|
40, 193, 108, 44, 69, 68, 1, 2, 3, 152,
|
48, 45, 55, 49, 183, 61, 58, 64, 140, 50,
|
4, 56, 127, 66, 128, 66, 203, 5, 45, 68,
|
64, 65, 143, 66, 136, 72, 66, 62, 52, 6,
|
143, 68, 187, 59, 146, 69, 112, 74, 113, 114,
|
7, 63, 172, 173, 8, 51, 1, 2, 3, 9,
|
62, 131, 63, 64, 176, 177, 65, 6, 7, 69,
|
4, 10, 11, 67, 200, 12, 67, 5, 176, 64,
|
73, 69, 8, 85, 87, 66, 204, 9, 18, 10,
|
53, 109, 191, 110, 111, 66, 83, 154, 155, 156,
|
11, 68, 86, 12, 88, 89, 19, 20, 21, 22,
|
157, 158, 159, 64, 71, 184, 185, 6, 7, 66,
|
158, 159, 160, 161, 162, 163, 23, 24, 25, 26,
|
189, 84, 8, 85, 124, 67, 125, 9, 86, 10,
|
27, 69, 94, 66, 66, 95, 97, 67, 139, 68,
|
11, 128, 87, 12, 92, 199, 1, 2, 3, 67,
|
68, 99, 101, 28, 126, 130, 49, 109, 110, 50,
|
4, 95, 93, 180, 181, 97, 99, 5, 19, 20,
|
1, 2, 3, 111, 4, 51, 118, 184, 185, 69,
|
21, 107, 192, 47, 1, 2, 3, 108, 4, 88,
|
69, 5, 19, 20, 21, 129, 195, 48, 1, 2,
|
193, 47, 47, 115, 123, 5, 47, 6, 7, 126,
|
3, 52, 4, 90, 197, 48, 48, 134, 132, 5,
|
194, 127, 8, 80, 81, 82, 47, 9, 129, 10,
|
48, 6, 7, 135, 196, 136, 8, 82, 83, 84,
|
11, 131, 132, 12, 133, 6, 7, 19, 20, 21,
|
48, 9, 137, 10, 11, 140, 141, 12, 142, 6,
|
8, 134, 1, 2, 3, 9, 4, 10, 11, 137,
|
7, 19, 20, 21, 8, 144, 1, 2, 3, 9,
|
138, 12, 139, 5, 74, 75, 76, 77, 201, 1,
|
4, 10, 11, 153, 154, 12, 155, 5, 76, 77,
|
2, 3, 141, 4, 100, 101, 102, 103, 150, 151,
|
78, 79, 198, 1, 2, 3, 156, 4, 102, 103,
|
5, 152, 153, 6, 7, 144, 145, 146, 8, 112,
|
104, 105, 157, 165, 5, 164, 166, 6, 7, 205,
|
113, 114, 160, 9, 164, 10, 11, 161, 166, 12,
|
167, 168, 8, 147, 148, 149, 170, 9, 172, 10,
|
6, 7, 162, 163, 168, 8, 177, 178, 179, 18,
|
11, 174, 175, 12, 6, 7, 115, 116, 117, 8,
|
9, 188, 10, 11, 18, 182, 12, 19, 20, 21,
|
181, 1, 2, 3, 9, 4, 10, 11, 18, 182,
|
22, 170, 19, 20, 21, 171, 186, 23, 24, 25,
|
12, 183, 5, 186, 190, 191, 19, 20, 21, 192,
|
26, 27, 23, 24, 25, 26, 27, 18, 190, 196,
|
194, 200, 202, 41, 201, 178, 23, 24, 25, 26,
|
40, 187, 197, 198, 174, 19, 20, 21, 130, 0,
|
27, 18, 6, 7, 133, 0, 0, 8, 0, 19,
|
0, 0, 0, 0, 0, 23, 90, 25, 26, 27
|
20, 21, 9, 28, 10, 11, 0, 0, 12, 23,
|
|
92, 25, 26, 27, 18, 0, 0, 0, 0, 0,
|
|
0, 0, 19, 20, 21, 0, 28, 0, 0, 0,
|
|
0, 0, 23, 24, 25, 26, 27
|
};
|
};
|
|
|
/* YYCHECK. */
|
/* YYCHECK. */
|
const short int
|
const short int
|
Parser::yycheck_[] =
|
Parser::yycheck_[] =
|
{
|
{
|
13, 18, 2, 97, 59, 16, 28, 0, 128, 35,
|
13, 18, 2, 99, 60, 21, 22, 16, 0, 20,
|
3, 4, 5, 27, 7, 135, 35, 28, 18, 16,
|
131, 3, 4, 5, 35, 7, 28, 138, 18, 28,
|
42, 14, 8, 9, 10, 11, 12, 13, 45, 21,
|
35, 27, 14, 8, 9, 10, 11, 12, 13, 46,
|
22, 42, 17, 17, 51, 35, 53, 23, 23, 23,
|
42, 42, 48, 42, 16, 52, 36, 54, 23, 164,
|
16, 34, 35, 29, 29, 29, 39, 28, 48, 104,
|
16, 28, 34, 35, 29, 40, 28, 39, 42, 49,
|
105, 44, 28, 46, 47, 35, 48, 50, 3, 4,
|
106, 107, 44, 17, 46, 47, 181, 182, 50, 23,
|
5, 61, 7, 49, 49, 49, 42, 40, 35, 14,
|
42, 186, 62, 35, 49, 29, 3, 4, 5, 17,
|
20, 42, 27, 23, 19, 16, 28, 23, 95, 29,
|
7, 27, 31, 23, 33, 23, 201, 14, 35, 29,
|
23, 27, 99, 29, 27, 85, 29, 16, 20, 34,
|
97, 29, 19, 28, 101, 49, 66, 87, 68, 69,
|
35, 16, 147, 148, 39, 45, 3, 4, 5, 44,
|
16, 41, 16, 16, 150, 151, 42, 34, 35, 49,
|
7, 46, 47, 49, 198, 50, 49, 14, 160, 23,
|
16, 49, 39, 35, 16, 23, 202, 44, 16, 46,
|
42, 64, 19, 66, 67, 29, 35, 117, 118, 119,
|
47, 29, 27, 50, 16, 16, 24, 25, 26, 27,
|
120, 121, 122, 23, 16, 177, 178, 34, 35, 29,
|
120, 121, 122, 123, 124, 125, 34, 35, 36, 37,
|
182, 27, 39, 16, 31, 49, 33, 44, 16, 46,
|
38, 49, 23, 23, 23, 29, 16, 27, 27, 29,
|
47, 41, 16, 50, 23, 197, 3, 4, 5, 49,
|
29, 41, 41, 51, 17, 17, 20, 34, 34, 23,
|
7, 16, 29, 170, 171, 41, 41, 14, 24, 25,
|
3, 4, 5, 35, 7, 29, 35, 174, 175, 49,
|
26, 34, 19, 176, 3, 4, 5, 34, 7, 35,
|
49, 14, 24, 25, 26, 31, 19, 180, 3, 4,
|
187, 184, 185, 35, 17, 14, 189, 34, 35, 31,
|
5, 45, 7, 35, 191, 188, 189, 17, 43, 14,
|
19, 17, 39, 30, 31, 32, 199, 44, 43, 46,
|
193, 34, 35, 17, 19, 43, 39, 30, 31, 32,
|
47, 17, 17, 50, 43, 34, 35, 24, 25, 26,
|
203, 44, 43, 46, 47, 27, 27, 50, 27, 34,
|
39, 43, 3, 4, 5, 44, 7, 46, 47, 27,
|
35, 24, 25, 26, 39, 43, 3, 4, 5, 44,
|
27, 50, 27, 14, 30, 31, 32, 33, 19, 3,
|
7, 46, 47, 17, 17, 50, 43, 14, 30, 31,
|
4, 5, 43, 7, 29, 30, 31, 32, 17, 17,
|
32, 33, 19, 3, 4, 5, 41, 7, 29, 30,
|
14, 41, 17, 34, 35, 30, 31, 32, 39, 68,
|
31, 32, 17, 33, 14, 18, 32, 34, 35, 19,
|
69, 70, 18, 44, 27, 46, 47, 33, 17, 50,
|
32, 27, 39, 30, 31, 32, 17, 44, 27, 46,
|
34, 35, 32, 32, 27, 39, 18, 18, 17, 16,
|
47, 41, 41, 50, 34, 35, 70, 71, 72, 39,
|
44, 17, 46, 47, 16, 18, 50, 24, 25, 26,
|
18, 3, 4, 5, 44, 7, 46, 47, 16, 18,
|
27, 41, 24, 25, 26, 41, 27, 34, 35, 36,
|
50, 17, 14, 18, 27, 41, 24, 25, 26, 17,
|
37, 38, 34, 35, 36, 37, 38, 16, 15, 17,
|
15, 17, 41, 7, 18, 156, 34, 35, 36, 37,
|
7, 41, 18, 41, 152, 24, 25, 26, 85, -1,
|
38, 16, 34, 35, 87, -1, -1, 39, -1, 24,
|
-1, -1, -1, -1, -1, 34, 35, 36, 37, 38
|
25, 26, 44, 51, 46, 47, -1, -1, 50, 34,
|
|
35, 36, 37, 38, 16, -1, -1, -1, -1, -1,
|
|
-1, -1, 24, 25, 26, -1, 51, -1, -1, -1,
|
|
-1, -1, 34, 35, 36, 37, 38
|
};
|
};
|
|
|
/* STOS_[STATE-NUM] -- The (internal number of the) accessing
|
/* STOS_[STATE-NUM] -- The (internal number of the) accessing
|
symbol of state STATE-NUM. */
|
symbol of state STATE-NUM. */
|
const unsigned char
|
const unsigned char
|
Parser::yystos_[] =
|
Parser::yystos_[] =
|
{
|
{
|
0, 3, 4, 5, 7, 14, 34, 35, 39, 44,
|
0, 3, 4, 5, 7, 14, 34, 35, 39, 44,
|
46, 47, 50, 52, 53, 66, 35, 69, 16, 24,
|
46, 47, 50, 53, 54, 67, 35, 70, 16, 24,
|
25, 26, 27, 34, 35, 36, 37, 38, 60, 61,
|
25, 26, 27, 34, 35, 36, 37, 38, 51, 61,
|
62, 63, 68, 35, 27, 16, 28, 16, 28, 42,
|
62, 63, 64, 69, 35, 27, 16, 28, 16, 28,
|
65, 40, 54, 35, 35, 42, 0, 53, 20, 23,
|
42, 66, 40, 55, 35, 35, 42, 0, 54, 20,
|
29, 45, 20, 42, 70, 27, 60, 68, 28, 28,
|
23, 29, 45, 20, 42, 71, 27, 61, 69, 28,
|
65, 16, 16, 16, 23, 27, 29, 49, 21, 22,
|
28, 66, 16, 16, 16, 42, 23, 27, 29, 49,
|
48, 16, 60, 67, 30, 31, 32, 33, 58, 60,
|
21, 22, 48, 16, 61, 68, 30, 31, 32, 33,
|
30, 31, 32, 35, 27, 16, 16, 16, 35, 68,
|
59, 61, 30, 31, 32, 35, 27, 16, 16, 16,
|
35, 60, 23, 29, 68, 16, 68, 41, 17, 41,
|
35, 69, 35, 61, 23, 29, 69, 16, 69, 41,
|
29, 30, 31, 32, 64, 64, 60, 34, 34, 61,
|
17, 41, 29, 30, 31, 32, 65, 65, 61, 34,
|
61, 61, 62, 62, 62, 35, 59, 8, 9, 10,
|
34, 35, 62, 62, 62, 63, 63, 63, 35, 60,
|
11, 12, 13, 17, 31, 33, 31, 17, 41, 43,
|
8, 9, 10, 11, 12, 13, 17, 31, 33, 31,
|
67, 17, 17, 43, 43, 16, 27, 27, 27, 27,
|
17, 41, 43, 68, 17, 17, 43, 43, 16, 27,
|
68, 43, 69, 68, 30, 31, 32, 64, 64, 17,
|
27, 27, 27, 69, 43, 70, 69, 30, 31, 32,
|
17, 17, 41, 17, 60, 60, 60, 60, 60, 60,
|
65, 65, 17, 17, 17, 43, 41, 17, 61, 61,
|
18, 33, 32, 32, 27, 58, 17, 57, 27, 58,
|
61, 61, 61, 61, 18, 33, 32, 32, 27, 59,
|
41, 41, 64, 64, 59, 56, 52, 18, 18, 17,
|
17, 58, 27, 59, 41, 41, 65, 65, 60, 57,
|
68, 68, 18, 19, 52, 52, 27, 41, 17, 52,
|
53, 18, 18, 17, 69, 69, 18, 19, 53, 53,
|
15, 19, 19, 68, 19, 55, 17, 18, 41, 52,
|
27, 41, 17, 53, 15, 19, 19, 69, 19, 56,
|
69, 19
|
17, 18, 41, 53, 70, 19
|
};
|
};
|
|
|
#if YYDEBUG
|
#if YYDEBUG
|
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
|
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
|
to YYLEX-NUM. */
|
to YYLEX-NUM. */
|
const unsigned short int
|
const unsigned short int
|
Parser::yytoken_number_[] =
|
Parser::yytoken_number_[] =
|
{
|
{
|
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
|
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
|
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
|
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
|
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
|
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
|
285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
|
285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
|
295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
|
295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
|
305
|
305, 306
|
};
|
};
|
#endif
|
#endif
|
|
|
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
const unsigned char
|
const unsigned char
|
Parser::yyr1_[] =
|
Parser::yyr1_[] =
|
{
|
{
|
0, 51, 52, 52, 52, 53, 53, 53, 53, 53,
|
0, 52, 53, 53, 53, 54, 54, 54, 54, 54,
|
53, 53, 53, 53, 54, 53, 55, 53, 53, 56,
|
54, 54, 54, 54, 55, 54, 56, 54, 54, 57,
|
53, 57, 53, 53, 53, 53, 58, 58, 58, 59,
|
54, 58, 54, 54, 54, 54, 59, 59, 59, 60,
|
59, 59, 60, 60, 60, 60, 61, 61, 61, 61,
|
60, 60, 61, 61, 61, 61, 61, 62, 62, 62,
|
62, 62, 62, 63, 63, 63, 63, 63, 63, 63,
|
62, 63, 63, 63, 64, 64, 64, 64, 64, 64,
|
63, 64, 64, 64, 64, 64, 64, 65, 65, 66,
|
64, 64, 65, 65, 65, 65, 65, 65, 66, 66,
|
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
|
67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
|
66, 66, 67, 67, 67, 67, 67, 67, 68, 68,
|
67, 67, 67, 68, 68, 68, 68, 68, 68, 69,
|
68, 69, 69, 69, 69, 70, 70
|
69, 69, 70, 70, 70, 70, 71, 71
|
};
|
};
|
|
|
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
const unsigned char
|
const unsigned char
|
Parser::yyr2_[] =
|
Parser::yyr2_[] =
|
{
|
{
|
0, 2, 0, 2, 1, 3, 3, 2, 3, 2,
|
0, 2, 0, 2, 1, 3, 3, 2, 3, 2,
|
4, 4, 4, 4, 0, 8, 0, 12, 7, 0,
|
4, 4, 4, 4, 0, 8, 0, 12, 7, 0,
|
9, 0, 8, 5, 7, 5, 0, 3, 1, 0,
|
9, 0, 8, 5, 7, 5, 0, 3, 1, 0,
|
3, 1, 3, 3, 3, 1, 3, 3, 3, 1,
|
3, 1, 3, 3, 3, 4, 1, 3, 3, 3,
|
1, 4, 3, 1, 7, 2, 5, 1, 4, 4,
|
1, 1, 4, 3, 1, 7, 2, 5, 1, 4,
|
5, 1, 2, 1, 2, 1, 2, 0, 3, 4,
|
4, 5, 1, 2, 1, 2, 1, 2, 0, 3,
|
4, 2, 3, 3, 3, 1, 3, 3, 3, 5,
|
4, 4, 2, 3, 3, 3, 1, 3, 3, 3,
|
5, 5, 3, 3, 3, 3, 3, 3, 1, 1,
|
5, 5, 5, 3, 3, 3, 3, 3, 3, 1,
|
1, 4, 11, 9, 2, 0, 3
|
1, 1, 4, 11, 9, 2, 0, 3
|
};
|
};
|
|
|
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
const char*
|
const char*
|
const Parser::yytname_[] =
|
const Parser::yytname_[] =
|
{
|
{
|
"$end", "error", "$undefined", "AUTO", "RETURN", "FUNCTION", "JMP",
|
"$end", "error", "$undefined", "AUTO", "RETURN", "FUNCTION", "JMP",
|
"EXIT", "EQUAL", "NOT_EQUAL", "GREATER_THAN", "LESS_THAN",
|
"EXIT", "EQUAL", "NOT_EQUAL", "GREATER_THAN", "LESS_THAN",
|
"LESS_OR_EQUAL_THAN", "GREATER_OR_EQUAL_THAN", "IF", "ELSE",
|
"LESS_OR_EQUAL_THAN", "GREATER_OR_EQUAL_THAN", "IF", "ELSE",
|
"OPEN_ROUND_BRACE", "CLOSE_ROUND_BRACE", "OPEN_BRACE", "CLOSE_BRACE",
|
"OPEN_ROUND_BRACE", "CLOSE_ROUND_BRACE", "OPEN_BRACE", "CLOSE_BRACE",
|
"ASSIGN", "DIV", "MUL", "ADD", "DECCONST", "HEXCONST", "BINCONST", "EOS",
|
"ASSIGN", "DIV", "MUL", "ADD", "DECCONST", "HEXCONST", "BINCONST", "EOS",
|
"DOT", "MINUS", "TK_X", "TK_Y", "TK_Z", "TK_N", "REG", "IDENTIFIER",
|
"DOT", "MINUS", "TK_X", "TK_Y", "TK_Z", "TK_N", "REG", "IDENTIFIER",
|
"SQRT", "SCALE", "UNSCALE", "USING", "FIXED_POINT", "COMMA",
|
"SQRT", "SCALE", "UNSCALE", "USING", "FIXED_POINT", "COMMA",
|
"OPEN_SQUARE_BRACE", "CLOSE_SQUARE_BRACE", "WHILE", "ADD_EQ", "THREAD",
|
"OPEN_SQUARE_BRACE", "CLOSE_SQUARE_BRACE", "WHILE", "ADD_EQ", "THREAD",
|
"START", "BITWISE_AND", "BITWISE_OR", "OUT", "$accept", "statement_list",
|
"START", "BITWISE_AND", "BITWISE_OR", "OUT", "IN", "$accept",
|
"statement", "$@1", "$@2", "$@3", "$@4", "function_input_list",
|
"statement_list", "statement", "$@1", "$@2", "$@3", "$@4",
|
"function_argument_list", "expression", "term", "factor", "source",
|
"function_input_list", "function_argument_list", "expression", "term",
|
"coordinate", "array_index", "left_hand_side", "boolean_expression",
|
"factor", "source", "coordinate", "array_index", "left_hand_side",
|
"constant", "auto_var_list", "array_size", 0
|
"boolean_expression", "constant", "auto_var_list", "array_size", 0
|
};
|
};
|
#endif
|
#endif
|
|
|
#if YYDEBUG
|
#if YYDEBUG
|
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
const Parser::rhs_number_type
|
const Parser::rhs_number_type
|
Parser::yyrhs_[] =
|
Parser::yyrhs_[] =
|
{
|
{
|
52, 0, -1, -1, 52, 53, -1, 53, -1, 3,
|
53, 0, -1, -1, 53, 54, -1, 54, -1, 3,
|
69, 27, -1, 39, 40, 27, -1, 7, 27, -1,
|
70, 27, -1, 39, 40, 27, -1, 7, 27, -1,
|
4, 60, 27, -1, 4, 27, -1, 66, 45, 68,
|
4, 61, 27, -1, 4, 27, -1, 67, 45, 69,
|
27, -1, 66, 29, 29, 27, -1, 66, 23, 23,
|
27, -1, 67, 29, 29, 27, -1, 67, 23, 23,
|
27, -1, 66, 20, 60, 27, -1, -1, 44, 54,
|
27, -1, 67, 20, 61, 27, -1, -1, 44, 55,
|
16, 67, 17, 18, 52, 19, -1, -1, 14, 16,
|
16, 68, 17, 18, 53, 19, -1, -1, 14, 16,
|
67, 17, 18, 52, 19, 15, 55, 18, 52, 19,
|
68, 17, 18, 53, 19, 15, 56, 18, 53, 19,
|
-1, 14, 16, 67, 17, 18, 52, 19, -1, -1,
|
-1, 14, 16, 68, 17, 18, 53, 19, -1, -1,
|
5, 35, 16, 59, 17, 56, 18, 52, 19, -1,
|
5, 35, 16, 60, 17, 57, 18, 53, 19, -1,
|
-1, 46, 35, 16, 17, 57, 18, 52, 19, -1,
|
-1, 46, 35, 16, 17, 58, 18, 53, 19, -1,
|
47, 35, 16, 17, 27, -1, 66, 20, 35, 16,
|
47, 35, 16, 17, 27, -1, 67, 20, 35, 16,
|
58, 17, 27, -1, 35, 16, 58, 17, 27, -1,
|
59, 17, 27, -1, 35, 16, 59, 17, 27, -1,
|
-1, 60, 41, 58, -1, 60, -1, -1, 35, 41,
|
-1, 61, 41, 59, -1, 61, -1, -1, 35, 41,
|
59, -1, 35, -1, 60, 23, 61, -1, 60, 29,
|
60, -1, 35, -1, 61, 23, 62, -1, 61, 29,
|
61, -1, 60, 49, 61, -1, 61, -1, 61, 22,
|
62, -1, 61, 49, 62, -1, 51, 42, 35, 43,
|
62, -1, 61, 21, 62, -1, 61, 48, 62, -1,
|
-1, 62, -1, 62, 22, 63, -1, 62, 21, 63,
|
62, -1, 63, -1, 36, 16, 60, 17, -1, 16,
|
-1, 62, 48, 63, -1, 63, -1, 64, -1, 36,
|
60, 17, -1, 68, -1, 16, 68, 41, 68, 41,
|
16, 61, 17, -1, 16, 61, 17, -1, 69, -1,
|
68, 17, -1, 35, 65, -1, 35, 28, 64, 64,
|
16, 69, 41, 69, 41, 69, 17, -1, 35, 66,
|
64, -1, 34, -1, 37, 16, 34, 17, -1, 38,
|
-1, 35, 28, 65, 65, 65, -1, 34, -1, 37,
|
16, 34, 17, -1, 34, 28, 64, 64, 64, -1,
|
16, 34, 17, -1, 38, 16, 34, 17, -1, 34,
|
30, -1, 29, 30, -1, 31, -1, 29, 31, -1,
|
28, 65, 65, 65, -1, 30, -1, 29, 30, -1,
|
32, -1, 29, 32, -1, -1, 42, 35, 43, -1,
|
31, -1, 29, 31, -1, 32, -1, 29, 32, -1,
|
50, 42, 68, 43, -1, 50, 42, 35, 43, -1,
|
-1, 42, 35, 43, -1, 50, 42, 69, 43, -1,
|
35, 65, -1, 35, 28, 30, -1, 35, 28, 31,
|
50, 42, 35, 43, -1, 35, 66, -1, 35, 28,
|
-1, 35, 28, 32, -1, 34, -1, 34, 28, 30,
|
30, -1, 35, 28, 31, -1, 35, 28, 32, -1,
|
-1, 34, 28, 31, -1, 34, 28, 32, -1, 34,
|
34, -1, 34, 28, 30, -1, 34, 28, 31, -1,
|
28, 30, 31, 33, -1, 34, 28, 30, 33, 32,
|
34, 28, 32, -1, 34, 28, 30, 31, 33, -1,
|
-1, 34, 28, 33, 31, 32, -1, 60, 9, 60,
|
34, 28, 30, 33, 32, -1, 34, 28, 33, 31,
|
-1, 60, 8, 60, -1, 60, 10, 60, -1, 60,
|
32, -1, 61, 9, 61, -1, 61, 8, 61, -1,
|
11, 60, -1, 60, 12, 60, -1, 60, 13, 60,
|
61, 10, 61, -1, 61, 11, 61, -1, 61, 12,
|
-1, 24, -1, 25, -1, 26, -1, 35, 70, 41,
|
61, -1, 61, 13, 61, -1, 24, -1, 25, -1,
|
69, -1, 35, 20, 16, 68, 41, 68, 41, 68,
|
26, -1, 35, 71, 41, 70, -1, 35, 20, 16,
|
17, 41, 69, -1, 35, 20, 16, 68, 41, 68,
|
69, 41, 69, 41, 69, 17, 41, 70, -1, 35,
|
41, 68, 17, -1, 35, 70, -1, -1, 42, 68,
|
20, 16, 69, 41, 69, 41, 69, 17, -1, 35,
|
43, -1
|
71, -1, -1, 42, 69, 43, -1
|
};
|
};
|
|
|
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
YYRHS. */
|
YYRHS. */
|
const unsigned short int
|
const unsigned short int
|
Parser::yyprhs_[] =
|
Parser::yyprhs_[] =
|
{
|
{
|
0, 0, 3, 4, 7, 9, 13, 17, 20, 24,
|
0, 0, 3, 4, 7, 9, 13, 17, 20, 24,
|
27, 32, 37, 42, 47, 48, 57, 58, 71, 79,
|
27, 32, 37, 42, 47, 48, 57, 58, 71, 79,
|
80, 90, 91, 100, 106, 114, 120, 121, 125, 127,
|
80, 90, 91, 100, 106, 114, 120, 121, 125, 127,
|
128, 132, 134, 138, 142, 146, 148, 152, 156, 160,
|
128, 132, 134, 138, 142, 146, 151, 153, 157, 161,
|
162, 164, 169, 173, 175, 183, 186, 192, 194, 199,
|
165, 167, 169, 174, 178, 180, 188, 191, 197, 199,
|
204, 210, 212, 215, 217, 220, 222, 225, 226, 230,
|
204, 209, 215, 217, 220, 222, 225, 227, 230, 231,
|
235, 240, 243, 247, 251, 255, 257, 261, 265, 269,
|
235, 240, 245, 248, 252, 256, 260, 262, 266, 270,
|
275, 281, 287, 291, 295, 299, 303, 307, 311, 313,
|
274, 280, 286, 292, 296, 300, 304, 308, 312, 316,
|
315, 317, 322, 334, 344, 347, 348
|
318, 320, 322, 327, 339, 349, 352, 353
|
};
|
};
|
|
|
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
|
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
|
const unsigned short int
|
const unsigned short int
|
Parser::yyrline_[] =
|
Parser::yyrline_[] =
|
{
|
{
|
0, 830, 830, 832, 834, 839, 841, 846, 863, 930,
|
0, 839, 839, 841, 843, 848, 850, 855, 872, 939,
|
958, 976, 1005, 1030, 1343, 1343, 1363, 1359, 1391, 1402,
|
967, 985, 1014, 1039, 1358, 1358, 1390, 1386, 1425, 1446,
|
1401, 1431, 1430, 1453, 1494, 1518, 1574, 1577, 1582, 1588,
|
1445, 1485, 1484, 1515, 1564, 1595, 1655, 1658, 1663, 1669,
|
1591, 1596, 1617, 1638, 1660, 1681, 1689, 1714, 1739, 1760,
|
1672, 1677, 1708, 1729, 1751, 1781, 1790, 1798, 1823, 1848,
|
1768, 1773, 1792, 1802, 1832, 1897, 1915, 1926, 1935, 1943,
|
1869, 1877, 1887, 1906, 1916, 1946, 2011, 2029, 2040, 2049,
|
1951, 1964, 1969, 1974, 1979, 1984, 1989, 1998, 2002, 2015,
|
2057, 2065, 2078, 2083, 2088, 2093, 2098, 2103, 2112, 2116,
|
2021, 2030, 2041, 2050, 2059, 2068, 2075, 2082, 2089, 2097,
|
2129, 2135, 2148, 2159, 2168, 2177, 2186, 2193, 2200, 2207,
|
2104, 2111, 2122, 2128, 2134, 2141, 2147, 2153, 2162, 2175,
|
2215, 2222, 2229, 2240, 2246, 2252, 2259, 2265, 2271, 2280,
|
2186, 2200, 2216, 2280, 2348, 2368, 2372
|
2293, 2304, 2318, 2334, 2398, 2466, 2486, 2490
|
};
|
};
|
|
|
// Print the state stack on the debug stream.
|
// Print the state stack on the debug stream.
|
void
|
void
|
Parser::yystack_print_ ()
|
Parser::yystack_print_ ()
|
{
|
{
|
*yycdebug_ << "Stack now";
|
*yycdebug_ << "Stack now";
|
for (state_stack_type::const_iterator i = yystate_stack_.begin ();
|
for (state_stack_type::const_iterator i = yystate_stack_.begin ();
|
i != yystate_stack_.end (); ++i)
|
i != yystate_stack_.end (); ++i)
|
*yycdebug_ << ' ' << *i;
|
*yycdebug_ << ' ' << *i;
|
*yycdebug_ << std::endl;
|
*yycdebug_ << std::endl;
|
}
|
}
|
|
|
// Report on the debug stream that the rule \a yyrule is going to be reduced.
|
// Report on the debug stream that the rule \a yyrule is going to be reduced.
|
void
|
void
|
Parser::yy_reduce_print_ (int yyrule)
|
Parser::yy_reduce_print_ (int yyrule)
|
{
|
{
|
unsigned int yylno = yyrline_[yyrule];
|
unsigned int yylno = yyrline_[yyrule];
|
int yynrhs = yyr2_[yyrule];
|
int yynrhs = yyr2_[yyrule];
|
/* Print the symbols being reduced, and their result. */
|
/* Print the symbols being reduced, and their result. */
|
*yycdebug_ << "Reducing stack by rule " << yyrule - 1
|
*yycdebug_ << "Reducing stack by rule " << yyrule - 1
|
<< " (line " << yylno << "):" << std::endl;
|
<< " (line " << yylno << "):" << std::endl;
|
/* The symbols being reduced. */
|
/* The symbols being reduced. */
|
for (int yyi = 0; yyi < yynrhs; yyi++)
|
for (int yyi = 0; yyi < yynrhs; yyi++)
|
YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
|
YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
|
yyrhs_[yyprhs_[yyrule] + yyi],
|
yyrhs_[yyprhs_[yyrule] + yyi],
|
&(yysemantic_stack_[(yynrhs) - (yyi + 1)]),
|
&(yysemantic_stack_[(yynrhs) - (yyi + 1)]),
|
&(yylocation_stack_[(yynrhs) - (yyi + 1)]));
|
&(yylocation_stack_[(yynrhs) - (yyi + 1)]));
|
}
|
}
|
#endif // YYDEBUG
|
#endif // YYDEBUG
|
|
|
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
Parser::token_number_type
|
Parser::token_number_type
|
Parser::yytranslate_ (int t)
|
Parser::yytranslate_ (int t)
|
{
|
{
|
static
|
static
|
const token_number_type
|
const token_number_type
|
translate_table[] =
|
translate_table[] =
|
{
|
{
|
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
|
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
|
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
|
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
|
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
|
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
|
45, 46, 47, 48, 49, 50
|
45, 46, 47, 48, 49, 50, 51
|
};
|
};
|
if ((unsigned int) t <= yyuser_token_number_max_)
|
if ((unsigned int) t <= yyuser_token_number_max_)
|
return translate_table[t];
|
return translate_table[t];
|
else
|
else
|
return yyundef_token_;
|
return yyundef_token_;
|
}
|
}
|
|
|
const int Parser::yyeof_ = 0;
|
const int Parser::yyeof_ = 0;
|
const int Parser::yylast_ = 309;
|
const int Parser::yylast_ = 336;
|
const int Parser::yynnts_ = 20;
|
const int Parser::yynnts_ = 20;
|
const int Parser::yyempty_ = -2;
|
const int Parser::yyempty_ = -2;
|
const int Parser::yyfinal_ = 46;
|
const int Parser::yyfinal_ = 47;
|
const int Parser::yyterror_ = 1;
|
const int Parser::yyterror_ = 1;
|
const int Parser::yyerrcode_ = 256;
|
const int Parser::yyerrcode_ = 256;
|
const int Parser::yyntokens_ = 51;
|
const int Parser::yyntokens_ = 52;
|
|
|
const unsigned int Parser::yyuser_token_number_max_ = 305;
|
const unsigned int Parser::yyuser_token_number_max_ = 306;
|
const Parser::token_number_type Parser::yyundef_token_ = 2;
|
const Parser::token_number_type Parser::yyundef_token_ = 2;
|
|
|
|
|
/* Line 1054 of lalr1.cc */
|
/* Line 1054 of lalr1.cc */
|
#line 28 "parser.y"
|
#line 28 "parser.y"
|
} // Theia
|
} // Theia
|
|
|
/* Line 1054 of lalr1.cc */
|
/* Line 1054 of lalr1.cc */
|
#line 3588 "parser.tab.c"
|
#line 3628 "parser.tab.c"
|
|
|
|
|
/* Line 1056 of lalr1.cc */
|
/* Line 1056 of lalr1.cc */
|
#line 2378 "parser.y"
|
#line 2496 "parser.y"
|
|
|
|
|
|
|
|
|
// Error function throws an exception (std::string) with the location and error message
|
// Error function throws an exception (std::string) with the location and error message
|
void Theia::Parser::error(const Theia::Parser::location_type &loc,
|
void Theia::Parser::error(const Theia::Parser::location_type &loc,
|
const std::string &msg) {
|
const std::string &msg) {
|
std::ostringstream ret;
|
std::ostringstream ret;
|
ret << "Parser Error at " << loc << ": " << msg;
|
ret << "Parser Error at " << loc << ": " << msg;
|
throw ret.str();
|
throw ret.str();
|
}
|
}
|
|
|
// Now that we have the Parser declared, we can declare the Scanner and implement
|
// Now that we have the Parser declared, we can declare the Scanner and implement
|
// the yylex function
|
// the yylex function
|
#include "Scanner.h"
|
#include "Scanner.h"
|
static int yylex(Theia::Parser::semantic_type * yylval,
|
static int yylex(Theia::Parser::semantic_type * yylval,
|
Theia::Parser::location_type * yylloc,
|
Theia::Parser::location_type * yylloc,
|
Theia::Scanner &scanner) {
|
Theia::Scanner &scanner) {
|
return scanner.yylex(yylval, yylloc);
|
return scanner.yylex(yylval, yylloc);
|
}
|
}
|
|
|
|
|
|
|