8015266: fix some -Wsign-compare warnings in adlc

Reviewed-by: kvn
This commit is contained in:
Christian Thalinger 2013-05-30 08:37:08 -07:00
parent 2e5f473752
commit 337a9c1432
5 changed files with 85 additions and 71 deletions

View file

@ -30,7 +30,7 @@ static FILE *errfile = stderr;
//--------------------------- utility functions -----------------------------
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 *upper = new char[strlen(str)+1];

View file

@ -65,9 +65,9 @@ void Dict::init() {
// Precompute table of null character hashes
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++) {
xsum[i] = (1<<shft[i])+1+xsum[i-1];
xsum[i] = (short) ((1 << shft[i]) + 1 + xsum[i-1]);
}
initflag = 1; // Never again
}
@ -288,7 +288,7 @@ int hashstr(const void *t) {
register const char *s = (const char *)t;
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
}
assert(k < (MAXID), "Exceeded maximum name length");

View file

@ -800,7 +800,7 @@ const char *InstructForm::opnd_ident(int idx) {
return _components.at(idx)->_name;
}
const char *InstructForm::unique_opnd_ident(int idx) {
const char* InstructForm::unique_opnd_ident(uint idx) {
uint i;
for (i = 1; i < num_opnds(); ++i) {
if (unique_opnds_idx(i) == idx) {
@ -1315,16 +1315,16 @@ void InstructForm::rep_var_format(FILE *fp, const char *rep_var) {
// Seach through operands to determine parameters unique positions.
void InstructForm::set_unique_opnds() {
uint* uniq_idx = NULL;
int nopnds = num_opnds();
uint nopnds = num_opnds();
uint num_uniq = nopnds;
int i;
uint i;
_uniq_idx_length = 0;
if (nopnds > 0) {
// Allocate index array. Worst case we're mapping from each
// 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.
_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++) {
uniq_idx[i] = i;
}
@ -1340,8 +1340,8 @@ void InstructForm::set_unique_opnds() {
_parameters.reset();
while ((name = _parameters.iter()) != NULL) {
count = 0;
int position = 0;
int uniq_position = 0;
uint position = 0;
uint uniq_position = 0;
_components.reset();
Component *comp = NULL;
if (sets_result()) {
@ -1364,8 +1364,7 @@ void InstructForm::set_unique_opnds() {
uniq_position = position;
}
}
if( comp->isa(Component::DEF)
&& comp->isa(Component::USE) ) {
if (comp->isa(Component::DEF) && comp->isa(Component::USE)) {
++position;
if (position != 1)
--position; // only use two slots for the 1st USE_DEF
@ -1373,13 +1372,17 @@ void InstructForm::set_unique_opnds() {
}
}
if (has_dupl_use) {
for( i = 1; i < nopnds; i++ )
if( i != uniq_idx[i] )
for (i = 1; i < nopnds; i++) {
if (i != uniq_idx[i]) {
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++;
}
}
num_uniq = j;
}
}
@ -2217,12 +2220,16 @@ RegClass* OperandForm::get_RegClass() const {
bool OperandForm::is_bound_register() const {
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;
if (name == NULL) {
return false;
}
int size = 0;
uint size = 0;
if (strcmp(name, "RegFlags") == 0) size = 1;
if (strcmp(name, "RegI") == 0) size = 1;
if (strcmp(name, "RegF") == 0) size = 1;
@ -2230,7 +2237,9 @@ bool OperandForm::is_bound_register() const {
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;
if (size == 0) {
return false;
}
return size == reg_class->size();
}

View file

@ -106,7 +106,7 @@ public:
const char *_ins_pipe; // Instruction Scheduling description class
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
ComponentList _components; // List of Components matches MachNode's
// operand structure
@ -273,13 +273,13 @@ public:
uint num_unique_opnds() { return _num_uniq; }
uint unique_opnds_idx(int idx) {
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];
} else {
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
// require special handling in some cases. Their position in this

View file

@ -463,8 +463,9 @@ static int pipeline_res_mask_initializer(
uint resources_used_exclusively = 0;
for (pipeclass->_resUsage.reset();
(piperesource = (const PipeClassResourceForm *)pipeclass->_resUsage.iter()) != NULL; )
(piperesource = (const PipeClassResourceForm*)pipeclass->_resUsage.iter()) != NULL; ) {
element_count++;
}
// Pre-compute the string length
int templen;
@ -499,8 +500,9 @@ static int pipeline_res_mask_initializer(
(piperesource = (const PipeClassResourceForm*)pipeclass->_resUsage.iter()) != NULL; ) {
int used_mask = pipeline->_resdict[piperesource->_resource]->is_resource()->mask();
if (!used_mask)
if (!used_mask) {
fprintf(stderr, "*** used_mask is 0 ***\n");
}
resources_used |= used_mask;
@ -509,8 +511,9 @@ static int pipeline_res_mask_initializer(
for (lb = 0; (used_mask & (1 << lb)) == 0; lb++);
for (ub = 31; (used_mask & (1 << ub)) == 0; ub--);
if (lb == ub)
if (lb == ub) {
resources_used_exclusively |= used_mask;
}
int formatlen =
sprintf(&resource_mask[templen], " %s(0x%0*x, %*d, %*d, %s %s(",
@ -526,7 +529,7 @@ static int pipeline_res_mask_initializer(
int cycles = piperesource->_cycles;
uint stage = pipeline->_stages.index(piperesource->_stage);
if (NameList::Not_in_list == stage) {
if ((uint)NameList::Not_in_list == stage) {
fprintf(stderr,
"pipeline_res_mask_initializer: "
"semantic error: "
@ -565,8 +568,9 @@ static int pipeline_res_mask_initializer(
}
resource_mask[templen] = 0;
if (last_comma)
if (last_comma) {
last_comma[0] = ' ';
}
// See if the same string is in the table
int ndx = pipeline_res_mask.index(resource_mask);
@ -589,8 +593,9 @@ static int pipeline_res_mask_initializer(
pipeline_res_args.addName(args);
}
else
else {
delete [] resource_mask;
}
delete [] res_mask;
//delete [] res_masks;
@ -1787,7 +1792,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) {
// Skip first unique operands.
for( i = 1; i < cur_num_opnds; i++ ) {
comp = node->_components.iter();
if( (int)i != node->unique_opnds_idx(i) ) {
if (i != node->unique_opnds_idx(i)) {
break;
}
new_num_opnds++;
@ -1795,7 +1800,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) {
// Replace not unique operands with next unique operands.
for( ; i < cur_num_opnds; i++ ) {
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.
if( j != node->unique_opnds_idx(j) ) {
fprintf(fp," set_opnd_array(%d, opnd_array(%d)->clone(C)); // %s\n",