提交 e280bff1 编写于 作者: T twisti

8015266: fix some -Wsign-compare warnings in adlc

Reviewed-by: kvn
上级 fde447f0
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
static FILE *errfile = stderr; static FILE *errfile = stderr;
//--------------------------- utility functions ----------------------------- //--------------------------- utility functions -----------------------------
inline char toUpper(char lower) { inline char toUpper(char lower) {
return (('a' <= lower && lower <= 'z') ? (lower + ('A'-'a')) : lower); return (('a' <= lower && lower <= 'z') ? ((char) (lower + ('A'-'a'))) : lower);
} }
char *toUpper(const char *str) { char *toUpper(const char *str) {
char *upper = new char[strlen(str)+1]; char *upper = new char[strlen(str)+1];
......
...@@ -64,18 +64,18 @@ void Dict::init() { ...@@ -64,18 +64,18 @@ void Dict::init() {
int i; int i;
// Precompute table of null character hashes // Precompute table of null character hashes
if( !initflag ) { // Not initializated yet? if (!initflag) { // Not initializated yet?
xsum[0] = (1<<shft[0])+1; // Initialize xsum[0] = (short) ((1 << shft[0]) + 1); // Initialize
for( i = 1; i < MAXID; i++) { for( i = 1; i < MAXID; i++) {
xsum[i] = (1<<shft[i])+1+xsum[i-1]; xsum[i] = (short) ((1 << shft[i]) + 1 + xsum[i-1]);
} }
initflag = 1; // Never again initflag = 1; // Never again
} }
_size = 16; // Size is a power of 2 _size = 16; // Size is a power of 2
_cnt = 0; // Dictionary is empty _cnt = 0; // Dictionary is empty
_bin = (bucket*)_arena->Amalloc_4(sizeof(bucket)*_size); _bin = (bucket*)_arena->Amalloc_4(sizeof(bucket) * _size);
memset(_bin,0,sizeof(bucket)*_size); memset(_bin, 0, sizeof(bucket) * _size);
} }
//------------------------------~Dict------------------------------------------ //------------------------------~Dict------------------------------------------
...@@ -287,11 +287,11 @@ int hashstr(const void *t) { ...@@ -287,11 +287,11 @@ int hashstr(const void *t) {
register int sum = 0; register int sum = 0;
register const char *s = (const char *)t; register const char *s = (const char *)t;
while( ((c = s[k]) != '\0') && (k < MAXID-1) ) { // Get characters till nul while (((c = s[k]) != '\0') && (k < MAXID-1)) { // Get characters till nul
c = (c<<1)+1; // Characters are always odd! c = (char) ((c << 1) + 1); // Characters are always odd!
sum += c + (c<<shft[k++]); // Universal hash function sum += c + (c << shft[k++]); // Universal hash function
} }
assert( k < (MAXID), "Exceeded maximum name length"); assert(k < (MAXID), "Exceeded maximum name length");
return (int)((sum+xsum[k]) >> 1); // Hash key, un-modulo'd table size return (int)((sum+xsum[k]) >> 1); // Hash key, un-modulo'd table size
} }
......
...@@ -796,11 +796,11 @@ uint InstructForm::num_opnds() { ...@@ -796,11 +796,11 @@ uint InstructForm::num_opnds() {
return num_opnds; return num_opnds;
} }
const char *InstructForm::opnd_ident(int idx) { const char* InstructForm::opnd_ident(int idx) {
return _components.at(idx)->_name; return _components.at(idx)->_name;
} }
const char *InstructForm::unique_opnd_ident(int idx) { const char* InstructForm::unique_opnd_ident(uint idx) {
uint i; uint i;
for (i = 1; i < num_opnds(); ++i) { for (i = 1; i < num_opnds(); ++i) {
if (unique_opnds_idx(i) == idx) { if (unique_opnds_idx(i) == idx) {
...@@ -1315,36 +1315,36 @@ void InstructForm::rep_var_format(FILE *fp, const char *rep_var) { ...@@ -1315,36 +1315,36 @@ void InstructForm::rep_var_format(FILE *fp, const char *rep_var) {
// Seach through operands to determine parameters unique positions. // Seach through operands to determine parameters unique positions.
void InstructForm::set_unique_opnds() { void InstructForm::set_unique_opnds() {
uint* uniq_idx = NULL; uint* uniq_idx = NULL;
int nopnds = num_opnds(); uint nopnds = num_opnds();
uint num_uniq = nopnds; uint num_uniq = nopnds;
int i; uint i;
_uniq_idx_length = 0; _uniq_idx_length = 0;
if ( nopnds > 0 ) { if (nopnds > 0) {
// Allocate index array. Worst case we're mapping from each // Allocate index array. Worst case we're mapping from each
// component back to an index and any DEF always goes at 0 so the // component back to an index and any DEF always goes at 0 so the
// length of the array has to be the number of components + 1. // length of the array has to be the number of components + 1.
_uniq_idx_length = _components.count() + 1; _uniq_idx_length = _components.count() + 1;
uniq_idx = (uint*) malloc(sizeof(uint)*(_uniq_idx_length)); uniq_idx = (uint*) malloc(sizeof(uint) * _uniq_idx_length);
for( i = 0; i < _uniq_idx_length; i++ ) { for (i = 0; i < _uniq_idx_length; i++) {
uniq_idx[i] = i; uniq_idx[i] = i;
} }
} }
// Do it only if there is a match rule and no expand rule. With an // Do it only if there is a match rule and no expand rule. With an
// expand rule it is done by creating new mach node in Expand() // expand rule it is done by creating new mach node in Expand()
// method. // method.
if ( nopnds > 0 && _matrule != NULL && _exprule == NULL ) { if (nopnds > 0 && _matrule != NULL && _exprule == NULL) {
const char *name; const char *name;
uint count; uint count;
bool has_dupl_use = false; bool has_dupl_use = false;
_parameters.reset(); _parameters.reset();
while( (name = _parameters.iter()) != NULL ) { while ((name = _parameters.iter()) != NULL) {
count = 0; count = 0;
int position = 0; uint position = 0;
int uniq_position = 0; uint uniq_position = 0;
_components.reset(); _components.reset();
Component *comp = NULL; Component *comp = NULL;
if( sets_result() ) { if (sets_result()) {
comp = _components.iter(); comp = _components.iter();
position++; position++;
} }
...@@ -1352,11 +1352,11 @@ void InstructForm::set_unique_opnds() { ...@@ -1352,11 +1352,11 @@ void InstructForm::set_unique_opnds() {
for (; (comp = _components.iter()) != NULL; ++position) { for (; (comp = _components.iter()) != NULL; ++position) {
// When the first component is not a DEF, // When the first component is not a DEF,
// leave space for the result operand! // leave space for the result operand!
if ( position==0 && (! comp->isa(Component::DEF)) ) { if (position==0 && (!comp->isa(Component::DEF))) {
++position; ++position;
} }
if( strcmp(name, comp->_name)==0 ) { if (strcmp(name, comp->_name) == 0) {
if( ++count > 1 ) { if (++count > 1) {
assert(position < _uniq_idx_length, "out of bounds"); assert(position < _uniq_idx_length, "out of bounds");
uniq_idx[position] = uniq_position; uniq_idx[position] = uniq_position;
has_dupl_use = true; has_dupl_use = true;
...@@ -1364,22 +1364,25 @@ void InstructForm::set_unique_opnds() { ...@@ -1364,22 +1364,25 @@ void InstructForm::set_unique_opnds() {
uniq_position = position; uniq_position = position;
} }
} }
if( comp->isa(Component::DEF) if (comp->isa(Component::DEF) && comp->isa(Component::USE)) {
&& comp->isa(Component::USE) ) {
++position; ++position;
if( position != 1 ) if (position != 1)
--position; // only use two slots for the 1st USE_DEF --position; // only use two slots for the 1st USE_DEF
} }
} }
} }
if( has_dupl_use ) { if (has_dupl_use) {
for( i = 1; i < nopnds; i++ ) for (i = 1; i < nopnds; i++) {
if( i != uniq_idx[i] ) if (i != uniq_idx[i]) {
break; break;
int j = i; }
for( ; i < nopnds; i++ ) }
if( i == uniq_idx[i] ) uint j = i;
for (; i < nopnds; i++) {
if (i == uniq_idx[i]) {
uniq_idx[i] = j++; uniq_idx[i] = j++;
}
}
num_uniq = j; num_uniq = j;
} }
} }
...@@ -2216,21 +2219,27 @@ RegClass* OperandForm::get_RegClass() const { ...@@ -2216,21 +2219,27 @@ RegClass* OperandForm::get_RegClass() const {
bool OperandForm::is_bound_register() const { bool OperandForm::is_bound_register() const {
RegClass *reg_class = get_RegClass(); RegClass* reg_class = get_RegClass();
if (reg_class == NULL) return false; if (reg_class == NULL) {
return false;
const char * name = ideal_type(globalAD->globalNames()); }
if (name == NULL) return false;
const char* name = ideal_type(globalAD->globalNames());
int size = 0; if (name == NULL) {
if (strcmp(name,"RegFlags")==0) size = 1; return false;
if (strcmp(name,"RegI")==0) size = 1; }
if (strcmp(name,"RegF")==0) size = 1;
if (strcmp(name,"RegD")==0) size = 2; uint size = 0;
if (strcmp(name,"RegL")==0) size = 2; if (strcmp(name, "RegFlags") == 0) size = 1;
if (strcmp(name,"RegN")==0) size = 1; if (strcmp(name, "RegI") == 0) size = 1;
if (strcmp(name,"RegP")==0) size = globalAD->get_preproc_def("_LP64") ? 2 : 1; if (strcmp(name, "RegF") == 0) size = 1;
if (size == 0) return false; if (strcmp(name, "RegD") == 0) size = 2;
if (strcmp(name, "RegL") == 0) size = 2;
if (strcmp(name, "RegN") == 0) size = 1;
if (strcmp(name, "RegP") == 0) size = globalAD->get_preproc_def("_LP64") ? 2 : 1;
if (size == 0) {
return false;
}
return size == reg_class->size(); return size == reg_class->size();
} }
......
...@@ -106,7 +106,7 @@ public: ...@@ -106,7 +106,7 @@ public:
const char *_ins_pipe; // Instruction Scheduling description class const char *_ins_pipe; // Instruction Scheduling description class
uint *_uniq_idx; // Indexes of unique operands uint *_uniq_idx; // Indexes of unique operands
int _uniq_idx_length; // Length of _uniq_idx array uint _uniq_idx_length; // Length of _uniq_idx array
uint _num_uniq; // Number of unique operands uint _num_uniq; // Number of unique operands
ComponentList _components; // List of Components matches MachNode's ComponentList _components; // List of Components matches MachNode's
// operand structure // operand structure
...@@ -272,14 +272,14 @@ public: ...@@ -272,14 +272,14 @@ public:
void set_unique_opnds(); void set_unique_opnds();
uint num_unique_opnds() { return _num_uniq; } uint num_unique_opnds() { return _num_uniq; }
uint unique_opnds_idx(int idx) { uint unique_opnds_idx(int idx) {
if( _uniq_idx != NULL && idx > 0 ) { if (_uniq_idx != NULL && idx > 0) {
assert(idx < _uniq_idx_length, "out of bounds"); assert((uint)idx < _uniq_idx_length, "out of bounds");
return _uniq_idx[idx]; return _uniq_idx[idx];
} else { } else {
return idx; return idx;
} }
} }
const char *unique_opnd_ident(int idx); // Name of operand at unique idx. const char *unique_opnd_ident(uint idx); // Name of operand at unique idx.
// Operands which are only KILLs aren't part of the input array and // Operands which are only KILLs aren't part of the input array and
// require special handling in some cases. Their position in this // require special handling in some cases. Their position in this
......
...@@ -463,8 +463,9 @@ static int pipeline_res_mask_initializer( ...@@ -463,8 +463,9 @@ static int pipeline_res_mask_initializer(
uint resources_used_exclusively = 0; uint resources_used_exclusively = 0;
for (pipeclass->_resUsage.reset(); for (pipeclass->_resUsage.reset();
(piperesource = (const PipeClassResourceForm *)pipeclass->_resUsage.iter()) != NULL; ) (piperesource = (const PipeClassResourceForm*)pipeclass->_resUsage.iter()) != NULL; ) {
element_count++; element_count++;
}
// Pre-compute the string length // Pre-compute the string length
int templen; int templen;
...@@ -482,8 +483,8 @@ static int pipeline_res_mask_initializer( ...@@ -482,8 +483,8 @@ static int pipeline_res_mask_initializer(
for (i = rescount; i > 0; i /= 10) for (i = rescount; i > 0; i /= 10)
maskdigit++; maskdigit++;
static const char * pipeline_use_cycle_mask = "Pipeline_Use_Cycle_Mask"; static const char* pipeline_use_cycle_mask = "Pipeline_Use_Cycle_Mask";
static const char * pipeline_use_element = "Pipeline_Use_Element"; static const char* pipeline_use_element = "Pipeline_Use_Element";
templen = 1 + templen = 1 +
(int)(strlen(pipeline_use_cycle_mask) + (int)strlen(pipeline_use_element) + (int)(strlen(pipeline_use_cycle_mask) + (int)strlen(pipeline_use_element) +
...@@ -496,11 +497,12 @@ static int pipeline_res_mask_initializer( ...@@ -496,11 +497,12 @@ static int pipeline_res_mask_initializer(
templen = 0; templen = 0;
for (pipeclass->_resUsage.reset(); for (pipeclass->_resUsage.reset();
(piperesource = (const PipeClassResourceForm *)pipeclass->_resUsage.iter()) != NULL; ) { (piperesource = (const PipeClassResourceForm*)pipeclass->_resUsage.iter()) != NULL; ) {
int used_mask = pipeline->_resdict[piperesource->_resource]->is_resource()->mask(); int used_mask = pipeline->_resdict[piperesource->_resource]->is_resource()->mask();
if (!used_mask) if (!used_mask) {
fprintf(stderr, "*** used_mask is 0 ***\n"); fprintf(stderr, "*** used_mask is 0 ***\n");
}
resources_used |= used_mask; resources_used |= used_mask;
...@@ -509,8 +511,9 @@ static int pipeline_res_mask_initializer( ...@@ -509,8 +511,9 @@ static int pipeline_res_mask_initializer(
for (lb = 0; (used_mask & (1 << lb)) == 0; lb++); for (lb = 0; (used_mask & (1 << lb)) == 0; lb++);
for (ub = 31; (used_mask & (1 << ub)) == 0; ub--); for (ub = 31; (used_mask & (1 << ub)) == 0; ub--);
if (lb == ub) if (lb == ub) {
resources_used_exclusively |= used_mask; resources_used_exclusively |= used_mask;
}
int formatlen = int formatlen =
sprintf(&resource_mask[templen], " %s(0x%0*x, %*d, %*d, %s %s(", sprintf(&resource_mask[templen], " %s(0x%0*x, %*d, %*d, %s %s(",
...@@ -526,7 +529,7 @@ static int pipeline_res_mask_initializer( ...@@ -526,7 +529,7 @@ static int pipeline_res_mask_initializer(
int cycles = piperesource->_cycles; int cycles = piperesource->_cycles;
uint stage = pipeline->_stages.index(piperesource->_stage); uint stage = pipeline->_stages.index(piperesource->_stage);
if (NameList::Not_in_list == stage) { if ((uint)NameList::Not_in_list == stage) {
fprintf(stderr, fprintf(stderr,
"pipeline_res_mask_initializer: " "pipeline_res_mask_initializer: "
"semantic error: " "semantic error: "
...@@ -534,8 +537,8 @@ static int pipeline_res_mask_initializer( ...@@ -534,8 +537,8 @@ static int pipeline_res_mask_initializer(
piperesource->_stage); piperesource->_stage);
exit(1); exit(1);
} }
uint upper_limit = stage+cycles-1; uint upper_limit = stage + cycles - 1;
uint lower_limit = stage-1; uint lower_limit = stage - 1;
uint upper_idx = upper_limit >> 5; uint upper_idx = upper_limit >> 5;
uint lower_idx = lower_limit >> 5; uint lower_idx = lower_limit >> 5;
uint upper_position = upper_limit & 0x1f; uint upper_position = upper_limit & 0x1f;
...@@ -543,7 +546,7 @@ static int pipeline_res_mask_initializer( ...@@ -543,7 +546,7 @@ static int pipeline_res_mask_initializer(
uint mask = (((uint)1) << upper_position) - 1; uint mask = (((uint)1) << upper_position) - 1;
while ( upper_idx > lower_idx ) { while (upper_idx > lower_idx) {
res_mask[upper_idx--] |= mask; res_mask[upper_idx--] |= mask;
mask = (uint)-1; mask = (uint)-1;
} }
...@@ -565,8 +568,9 @@ static int pipeline_res_mask_initializer( ...@@ -565,8 +568,9 @@ static int pipeline_res_mask_initializer(
} }
resource_mask[templen] = 0; resource_mask[templen] = 0;
if (last_comma) if (last_comma) {
last_comma[0] = ' '; last_comma[0] = ' ';
}
// See if the same string is in the table // See if the same string is in the table
int ndx = pipeline_res_mask.index(resource_mask); int ndx = pipeline_res_mask.index(resource_mask);
...@@ -580,7 +584,7 @@ static int pipeline_res_mask_initializer( ...@@ -580,7 +584,7 @@ static int pipeline_res_mask_initializer(
fprintf(fp_cpp, "static const Pipeline_Use_Element pipeline_res_mask_%03d[%d] = {\n%s};\n\n", fprintf(fp_cpp, "static const Pipeline_Use_Element pipeline_res_mask_%03d[%d] = {\n%s};\n\n",
ndx+1, element_count, resource_mask); ndx+1, element_count, resource_mask);
char * args = new char [9 + 2*masklen + maskdigit]; char* args = new char [9 + 2*masklen + maskdigit];
sprintf(args, "0x%0*x, 0x%0*x, %*d", sprintf(args, "0x%0*x, 0x%0*x, %*d",
masklen, resources_used, masklen, resources_used,
...@@ -589,8 +593,9 @@ static int pipeline_res_mask_initializer( ...@@ -589,8 +593,9 @@ static int pipeline_res_mask_initializer(
pipeline_res_args.addName(args); pipeline_res_args.addName(args);
} }
else else {
delete [] resource_mask; delete [] resource_mask;
}
delete [] res_mask; delete [] res_mask;
//delete [] res_masks; //delete [] res_masks;
...@@ -1787,7 +1792,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { ...@@ -1787,7 +1792,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) {
// Skip first unique operands. // Skip first unique operands.
for( i = 1; i < cur_num_opnds; i++ ) { for( i = 1; i < cur_num_opnds; i++ ) {
comp = node->_components.iter(); comp = node->_components.iter();
if( (int)i != node->unique_opnds_idx(i) ) { if (i != node->unique_opnds_idx(i)) {
break; break;
} }
new_num_opnds++; new_num_opnds++;
...@@ -1795,7 +1800,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { ...@@ -1795,7 +1800,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) {
// Replace not unique operands with next unique operands. // Replace not unique operands with next unique operands.
for( ; i < cur_num_opnds; i++ ) { for( ; i < cur_num_opnds; i++ ) {
comp = node->_components.iter(); comp = node->_components.iter();
int j = node->unique_opnds_idx(i); uint j = node->unique_opnds_idx(i);
// unique_opnds_idx(i) is unique if unique_opnds_idx(j) is not unique. // unique_opnds_idx(i) is unique if unique_opnds_idx(j) is not unique.
if( j != node->unique_opnds_idx(j) ) { if( j != node->unique_opnds_idx(j) ) {
fprintf(fp," set_opnd_array(%d, opnd_array(%d)->clone(C)); // %s\n", fprintf(fp," set_opnd_array(%d, opnd_array(%d)->clone(C)); // %s\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册