From a937a4b354b60999a011970d054cd6c478be130d Mon Sep 17 00:00:00 2001 From: Jimmy Kwa Date: Mon, 15 Nov 2010 13:10:19 -0800 Subject: Cleaned up decuda_to_ptxplus code to remove compiler warnings [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 8119] --- decuda_to_ptxplus/decuda.l | 1 - decuda_to_ptxplus/decuda.y | 8 +++-- decuda_to_ptxplus/decudaInst.cc | 58 ++++++++++++++++++------------------- decuda_to_ptxplus/decudaInst.h | 24 +++++++-------- decuda_to_ptxplus/decudaInstList.cc | 4 +-- decuda_to_ptxplus/decudaInstList.h | 6 ++-- decuda_to_ptxplus/ptx_parser.h | 12 ++++---- decuda_to_ptxplus/stringList.h | 2 +- 8 files changed, 59 insertions(+), 56 deletions(-) (limited to 'decuda_to_ptxplus') diff --git a/decuda_to_ptxplus/decuda.l b/decuda_to_ptxplus/decuda.l index e47a4c7..6f576ee 100644 --- a/decuda_to_ptxplus/decuda.l +++ b/decuda_to_ptxplus/decuda.l @@ -133,7 +133,6 @@ return yylval.string_value = strdup(yytext); return RETURN; \.le yylval.string_value = strdup(yytext); return DOTLE; \.gt yylval.string_value = strdup(yytext); return DOTGT; \.ge yylval.string_value = strdup(yytext); return DOTGE; -\.lo yylval.string_value = strdup(yytext); return DOTLO; \.ls yylval.string_value = strdup(yytext); return DOTLS; \.hi yylval.string_value = strdup(yytext); return DOTHI; \.hs yylval.string_value = strdup(yytext); return DOTHS; diff --git a/decuda_to_ptxplus/decuda.y b/decuda_to_ptxplus/decuda.y index 52065d2..d4a18f6 100644 --- a/decuda_to_ptxplus/decuda.y +++ b/decuda_to_ptxplus/decuda.y @@ -285,8 +285,12 @@ constMemoryStatements : constMemoryStatement constMemoryStatement : POUND constMemoryTypes constMemoryList { g_instList->setConstMemoryType($2); } NEWLINE -constMemoryTypes : DDOTU32 { $$=".u32"} - | DDOTF32 { $$=".f32"} +constMemoryTypes : DDOTU32 { char tempString[5]; + strcpy(tempString, ".u32"); + $$ = tempString; } + | DDOTF32 { char tempString[5]; + strcpy(tempString, ".f32"); + $$ = tempString; } ; constMemoryList : constMemory diff --git a/decuda_to_ptxplus/decudaInst.cc b/decuda_to_ptxplus/decudaInst.cc index 3e5a402..2328bc2 100644 --- a/decuda_to_ptxplus/decudaInst.cc +++ b/decuda_to_ptxplus/decudaInst.cc @@ -25,7 +25,7 @@ decudaInst::decudaInst() } //retreive instruction mnemonic -char* decudaInst::getBase() +const char* decudaInst::getBase() { return m_base; } @@ -52,12 +52,12 @@ decudaInst* decudaInst::getNextDecudaInst() return m_nextDecudaInst; } -void decudaInst::setBase(char* setBaseValue) +void decudaInst::setBase(const char* setBaseValue) { m_base = setBaseValue; } -void decudaInst::addBaseModifier(char* addBaseMod) +void decudaInst::addBaseModifier(const char* addBaseMod) { stringListPiece* tempPiece = new stringListPiece; tempPiece->stringText = addBaseMod; @@ -65,7 +65,7 @@ void decudaInst::addBaseModifier(char* addBaseMod) m_baseModifiers->add(tempPiece); } -void decudaInst::addTypeModifier(char* addTypeMod) +void decudaInst::addTypeModifier(const char* addTypeMod) { stringListPiece* tempPiece = new stringListPiece; tempPiece->stringText = addTypeMod; @@ -73,7 +73,7 @@ void decudaInst::addTypeModifier(char* addTypeMod) m_typeModifiers->add(tempPiece); } -void decudaInst::addOperand(char* addOp) +void decudaInst::addOperand(const char* addOp) { stringListPiece* tempPiece = new stringListPiece; tempPiece->stringText = addOp; @@ -81,12 +81,12 @@ void decudaInst::addOperand(char* addOp) m_operands->add(tempPiece); } -void decudaInst::setPredicate(char* setPredicateValue) +void decudaInst::setPredicate(const char* setPredicateValue) { m_predicate = setPredicateValue; } -void decudaInst::addPredicateModifier(char* addPredicateMod) +void decudaInst::addPredicateModifier(const char* addPredicateMod) { stringListPiece* tempPiece = new stringListPiece; tempPiece->stringText = addPredicateMod; @@ -94,7 +94,7 @@ void decudaInst::addPredicateModifier(char* addPredicateMod) m_predicateModifiers->add(tempPiece); } -void decudaInst::setLabel(char* setLabelValue) +void decudaInst::setLabel(const char* setLabelValue) { m_label = setLabelValue; } @@ -332,7 +332,7 @@ void decudaInst::printTypeModifiers() void decudaInst::printOperands() { stringListPiece* currentPiece = m_operands->getListStart(); - char* operandDelimiter = ""; + const char* operandDelimiter = ""; for(int i=0; (igetSize())&&(currentPiece!=NULL); i++) { output(operandDelimiter); output(" "); output(currentPiece->stringText); @@ -355,9 +355,9 @@ void decudaInst::printNewPtx() currentPiece = m_operands->getListStart(); for(int i=0; (igetSize())&&(currentPiece!=NULL); i++) { - char* modString = currentPiece->stringText; + const char* modString = currentPiece->stringText; if( strcmp(modString, "%%clock")==0 ) { - char* newText = "%%halfclock"; + const char* newText = "%%halfclock"; currentPiece->stringText = newText; } currentPiece = currentPiece->nextString; @@ -367,7 +367,7 @@ void decudaInst::printNewPtx() currentPiece = m_baseModifiers->getListStart(); for(int i=0; (igetSize())&&(currentPiece!=NULL); i++) { - char* modString = currentPiece->stringText; + const char* modString = currentPiece->stringText; if( strcmp(modString, ".join")==0 ) { m_baseModifiers->remove(i); } @@ -378,9 +378,9 @@ void decudaInst::printNewPtx() currentPiece = m_baseModifiers->getListStart(); for(int i=0; (igetSize())&&(currentPiece!=NULL); i++) { - char* modString = currentPiece->stringText; + const char* modString = currentPiece->stringText; if( strcmp(modString, ".end")==0 ) { - char* newText = ".exit"; + const char* newText = ".exit"; currentPiece->stringText = newText; } currentPiece = currentPiece->nextString; @@ -391,14 +391,14 @@ void decudaInst::printNewPtx() currentPiece = m_typeModifiers->getListStart(); for(int i=0; (igetSize())&&(currentPiece!=NULL); i++) { - char* modString = currentPiece->stringText; + const char* modString = currentPiece->stringText; if( strcmp(modString, ".b64")==0 ) { - char* newText = ".bb64"; + const char* newText = ".bb64"; currentPiece->stringText = newText; vectorFlag = 1; } if( strcmp(modString, ".b128")==0 ) { - char* newText = ".bb128"; + const char* newText = ".bb128"; currentPiece->stringText = newText; vectorFlag = 2; } @@ -415,7 +415,7 @@ void decudaInst::printNewPtx() char *regNumString; int regNumInt; - char* modString = currentPiece->stringText; + const char* modString = currentPiece->stringText; if( modString[0] == '$' && modString[1] == 'r' ) { strcpy(newText, modString); strtok (newText, "r"); @@ -542,7 +542,7 @@ void decudaInst::printNewPtx() stringListPiece* currentPiece = m_baseModifiers->getListStart(); for(int i=0; (igetSize())&&(currentPiece!=NULL); i++) { - char* modString = currentPiece->stringText; + const char* modString = currentPiece->stringText; if( strcmp(modString, ".abs")==0 ) { cvt_inst_type = 1; } @@ -559,7 +559,7 @@ void decudaInst::printNewPtx() output("abs"); - char* type = m_typeModifiers->getListStart()->stringText; + const char* type = m_typeModifiers->getListStart()->stringText; output(type); printOperands(); @@ -593,12 +593,12 @@ void decudaInst::printNewPtx() else stringListPiece* currentPiece = m_baseModifiers->getListStart()->nextString; - char* dstType = m_typeModifiers->getListStart()->stringText; - char* srcType = m_typeModifiers->getListStart()->nextString->stringText; + const char* dstType = m_typeModifiers->getListStart()->stringText; + const char* srcType = m_typeModifiers->getListStart()->nextString->stringText; for(int i=0; (igetSize())&&(currentPiece!=NULL); i++) { - char* modString = currentPiece->stringText; + const char* modString = currentPiece->stringText; if( (strcmp(modString, ".rn")==0) || (strcmp(modString, ".rm")==0) || @@ -869,7 +869,7 @@ void decudaInst::printNewPtx() printDefaultPtx(); // opPerCycle - lower if a 32-bit integer mul - char* dstType = m_typeModifiers->getListStart()->stringText; + const char* dstType = m_typeModifiers->getListStart()->stringText; if( strcmp(dstType, ".s32")==0 || strcmp(dstType, ".u32")==0 || strcmp(dstType, ".b32")==0 ) m_opPerCycle = 2; } @@ -954,7 +954,7 @@ void decudaInst::printNewPtx() printDefaultPtx(); // opPerCycle - lower if a 32-bit integer mad - char* dstType = m_typeModifiers->getListStart()->stringText; + const char* dstType = m_typeModifiers->getListStart()->stringText; if( strcmp(dstType, ".s32")==0 || strcmp(dstType, ".u32")==0 || strcmp(dstType, ".b32")==0 ) m_opPerCycle = 2; } @@ -1191,7 +1191,7 @@ void decudaInst::printNewPtx() output(";"); // opPerCycle - lower if a 32-bit integer mac - char* dstType = m_typeModifiers->getListStart()->stringText; + const char* dstType = m_typeModifiers->getListStart()->stringText; if( strcmp(dstType, ".s32")==0 || strcmp(dstType, ".u32")==0 || strcmp(dstType, ".b32")==0 ) m_opPerCycle = 2; } @@ -1310,9 +1310,9 @@ void decudaInst::printNewPtx() output("Error: subr instruction with number of operands other than 3.\n"); assert(0); } - char* firstOperand = m_operands->getListStart()->stringText; - char* secondOperand = m_operands->getListStart()->nextString->stringText; - char* thirdOperand = m_operands->getListStart()->nextString->nextString->stringText; + const char* firstOperand = m_operands->getListStart()->stringText; + const char* secondOperand = m_operands->getListStart()->nextString->stringText; + const char* thirdOperand = m_operands->getListStart()->nextString->nextString->stringText; output(" "); output(firstOperand); output(","); output(" "); output(thirdOperand); output(","); output(" "); output(secondOperand); diff --git a/decuda_to_ptxplus/decudaInst.h b/decuda_to_ptxplus/decudaInst.h index a1f0a8e..8b73cf1 100644 --- a/decuda_to_ptxplus/decudaInst.h +++ b/decuda_to_ptxplus/decudaInst.h @@ -4,11 +4,11 @@ class decudaInst { -private: +protected: //instruction data - char* m_label; //instruction label - char* m_predicate; //instruction predicate - char* m_base; //instruction mnemonic + const char* m_label; //instruction label + const char* m_predicate; //instruction predicate + const char* m_base; //instruction mnemonic stringList* m_baseModifiers; //base modifiers stringList* m_typeModifiers; //operand types stringList* m_operands; //operands @@ -34,7 +34,7 @@ public: decudaInst(); //accessors - char* getBase(); + const char* getBase(); stringList* getOperands(); stringList* getBaseModifiers(); stringList* getTypeModifiers(); @@ -45,13 +45,13 @@ public: bool isEntryStart(); // true if start of an entry //mutators - void setBase(char* setBaseValue); - void addBaseModifier(char* addBaseMod); - void addTypeModifier(char* addTypeMod); - void addOperand(char* addOp); - void setPredicate(char* setPredicateValue); - void addPredicateModifier(char* addPredicateMod); - void setLabel(char* setLabelValue); + void setBase(const char* setBaseValue); + void addBaseModifier(const char* addBaseMod); + void addTypeModifier(const char* addTypeMod); + void addOperand(const char* addOp); + void setPredicate(const char* setPredicateValue); + void addPredicateModifier(const char* addPredicateMod); + void setLabel(const char* setLabelValue); void setNextDecudaInst(decudaInst* setDecudaInstValue); diff --git a/decuda_to_ptxplus/decudaInstList.cc b/decuda_to_ptxplus/decudaInstList.cc index 4605e64..9ac6f43 100644 --- a/decuda_to_ptxplus/decudaInstList.cc +++ b/decuda_to_ptxplus/decudaInstList.cc @@ -301,7 +301,7 @@ void decudaInstList::addRegister(std::string reg, bool lo) currentPiece = typeModifiers->getListStart(); for(int i=0; (igetSize())&&(currentPiece!=NULL); i++) { - char* modString = currentPiece->stringText; + const char* modString = currentPiece->stringText; if( strcmp(modString, ".b64")==0 ) vectorFlag = 64; @@ -451,7 +451,7 @@ void decudaInstList::addConstMemoryValue(std::string constMemoryValue) } // set type of constant memory -void decudaInstList::setConstMemoryType(char* type) +void decudaInstList::setConstMemoryType(const char* type) { m_constMemoryList.back().type = type; } diff --git a/decuda_to_ptxplus/decudaInstList.h b/decuda_to_ptxplus/decudaInstList.h index 649a5f5..d1707c3 100644 --- a/decuda_to_ptxplus/decudaInstList.h +++ b/decuda_to_ptxplus/decudaInstList.h @@ -14,7 +14,7 @@ struct constMemory { int index; int entryIndex; - char* type; + const char* type; std::list m_constMemory; }; @@ -65,7 +65,7 @@ struct decudaEntry class decudaInstList { -private: +protected: // List of decuda entries std::list m_entryList; @@ -125,7 +125,7 @@ public: // Parsing constant memory segments list void addEntryConstMemory(int index); // add entry specific const memory void addConstMemory(int index); // add global const memory - void setConstMemoryType(char* type); // set type of constant memory + void setConstMemoryType(const char* type); // set type of constant memory void addConstMemoryValue(std::string constMemoryValue); // add const memory std::list getRealTexList(); // get the list of real tex names diff --git a/decuda_to_ptxplus/ptx_parser.h b/decuda_to_ptxplus/ptx_parser.h index c0b31b8..1c9fc8c 100644 --- a/decuda_to_ptxplus/ptx_parser.h +++ b/decuda_to_ptxplus/ptx_parser.h @@ -61,7 +61,7 @@ void change_memory_addr_space( const char *a ) {} void add_literal_int( int a ) {} void add_literal_float( float a ) {} void add_literal_double( double a ) {} -void func_header_info_int(char*, int) {} +void func_header_info_int(const char*, int) {} void add_extern_spec() {} void add_alignment_spec( int ) {} void add_pragma( const char *a ) {} @@ -88,7 +88,7 @@ bool inTexDirective = false; void add_function_name( const char *headerInput ) { char* headerInfo = (char*) headerInput; - char* compareString = g_headerList->getListEnd().getBase(); + const char* compareString = g_headerList->getListEnd().getBase(); if((strcmp(compareString, ".entry")==0)||(strcmp(compareString, ".func")==0)) { @@ -120,7 +120,7 @@ void add_space_spec( enum _memory_space_t spec, int value ) void add_scalar_type_spec( int headerInput ) { - char* compareString = g_headerList->getListEnd().getBase(); + const char* compareString = g_headerList->getListEnd().getBase(); if( (inEntryDirective && inParamDirective) || inTexDirective) { @@ -244,7 +244,7 @@ void* reset_symtab() return a; } -void func_header(char* headerBase) +void func_header(const char* headerBase) { // If start of an entry @@ -258,9 +258,9 @@ void func_header(char* headerBase) } } -void func_header_info(char* headerInfo) +void func_header_info(const char* headerInfo) { - char* compareString = g_headerList->getListEnd().getBase(); + const char* compareString = g_headerList->getListEnd().getBase(); if(inEntryDirective) { g_headerList->getListEnd().addOperand(headerInfo); diff --git a/decuda_to_ptxplus/stringList.h b/decuda_to_ptxplus/stringList.h index 25d10f7..5460396 100644 --- a/decuda_to_ptxplus/stringList.h +++ b/decuda_to_ptxplus/stringList.h @@ -1,6 +1,6 @@ struct stringListPiece { - char* stringText; + const char* stringText; stringListPiece* nextString; }; -- cgit v1.3