Fixed warnings in Reactor

Fixed:
- type comparison mismatch
- redefined macros
- unused functions
- line endings

Change-Id: I965ca4b887aee968e6cf95feb36c3cbf90b85580
Reviewed-on: https://swiftshader-review.googlesource.com/8528
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Reactor/Optimizer.cpp b/src/Reactor/Optimizer.cpp
index ca3d7a3..75b225e 100644
--- a/src/Reactor/Optimizer.cpp
+++ b/src/Reactor/Optimizer.cpp
@@ -135,7 +135,7 @@
 
 					for(Ice::Inst *use : uses[loadData])
 					{
-						for(int i = 0; i < use->getSrcSize(); i++)
+						for(Ice::SizeT i = 0; i < use->getSrcSize(); i++)
 						{
 							if(use->getSrc(i) == loadData)
 							{
@@ -201,7 +201,7 @@
 
 					replace(load, storeValue);
 
-					for(int i = 0; i < addressUses.loads.size(); i++)
+					for(size_t i = 0; i < addressUses.loads.size(); i++)
 					{
 						if(addressUses.loads[i] == load)
 						{
@@ -211,7 +211,7 @@
 						}
 					}
 
-					for(int i = 0; i < addressUses.size(); i++)
+					for(size_t i = 0; i < addressUses.size(); i++)
 					{
 						if(addressUses[i] == load)
 						{
@@ -231,7 +231,7 @@
 
 						auto &valueUses = uses[storeValue];
 
-						for(int i = 0; i < valueUses.size(); i++)
+						for(size_t i = 0; i < valueUses.size(); i++)
 						{
 							if(valueUses[i] == store)
 							{
@@ -280,7 +280,7 @@
 
 			Ice::CfgNode *singleBasicBlock = node[addressUses.stores[0]];
 
-			for(int i = 1; i < addressUses.stores.size(); i++)
+			for(size_t i = 1; i < addressUses.stores.size(); i++)
 			{
 				Ice::Inst *store = addressUses.stores[i];
 				if(node[store] != singleBasicBlock)
@@ -356,9 +356,9 @@
 				node[&instruction] = basicBlock;
 				definition[instruction.getDest()] = &instruction;
 
-				for(int i = 0; i < instruction.getSrcSize(); i++)
+				for(Ice::SizeT i = 0; i < instruction.getSrcSize(); i++)
 				{
-					int unique = 0;
+					Ice::SizeT unique = 0;
 					for(; unique < i; unique++)
 					{
 						if(instruction.getSrc(i) == instruction.getSrc(unique))
@@ -390,7 +390,7 @@
 		{
 			assert(!use->isDeleted());   // Should have been removed from uses already
 
-			for(int i = 0; i < use->getSrcSize(); i++)
+			for(Ice::SizeT i = 0; i < use->getSrcSize(); i++)
 			{
 				if(use->getSrc(i) == oldValue)
 				{
@@ -415,7 +415,7 @@
 
 		instruction->setDeleted();
 
-		for(int i = 0; i < instruction->getSrcSize(); i++)
+		for(Ice::SizeT i = 0; i < instruction->getSrcSize(); i++)
 		{
 			Ice::Operand *src = instruction->getSrc(i);
 
@@ -583,14 +583,14 @@
 	{
 		auto &uses = *this;
 
-		for(int i = 0; i < uses.size(); i++)
+		for(size_t i = 0; i < uses.size(); i++)
 		{
 			if(uses[i] == instruction)
 			{
 				uses[i] = back();
 				pop_back();
 
-				for(int i = 0; i < loads.size(); i++)
+				for(size_t i = 0; i < loads.size(); i++)
 				{
 					if(loads[i] == instruction)
 					{
@@ -600,7 +600,7 @@
 					}
 				}
 
-				for(int i = 0; i < stores.size(); i++)
+				for(size_t i = 0; i < stores.size(); i++)
 				{
 					if(stores[i] == instruction)
 					{
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index 07c486f..2a5bad0 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -31,8 +31,12 @@
 #include "llvm/Support/raw_os_ostream.h"
 
 #if defined(_WIN32)
+#ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
+#endif // !WIN32_LEAN_AND_MEAN
+#ifndef NOMINMAX
 #define NOMINMAX
+#endif // !NOMINMAX
 #include <Windows.h>
 #else
 #include <sys/mman.h>
@@ -109,7 +113,7 @@
 
 	Ice::Type T(Type *t)
 	{
-		static_assert(Ice::IceType_NUM < EmulatedBits, "Ice::Type overlaps with our emulated types!");
+		static_assert(static_cast<unsigned int>(Ice::IceType_NUM) < static_cast<unsigned int>(EmulatedBits), "Ice::Type overlaps with our emulated types!");
 		return (Ice::Type)(reinterpret_cast<std::intptr_t>(t) & ~EmulatedBits);
 	}
 
@@ -292,20 +296,20 @@
 			{
 				assert(sizeof(void*) == 4 && "UNIMPLEMENTED");   // Only expected/implemented for 32-bit code
 
-				for(int index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
+				for(Elf32_Word index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
 				{
 					const Elf32_Rel &relocation = ((const Elf32_Rel*)(elfImage + sectionHeader[i].sh_offset))[index];
-					void *symbol = relocateSymbol(elfHeader, relocation, sectionHeader[i]);
+					relocateSymbol(elfHeader, relocation, sectionHeader[i]);
 				}
 			}
 			else if(sectionHeader[i].sh_type == SHT_RELA)
 			{
 				assert(sizeof(void*) == 8 && "UNIMPLEMENTED");   // Only expected/implemented for 64-bit code
 
-				for(int index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
+				for(Elf32_Word index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
 				{
 					const Elf64_Rela &relocation = ((const Elf64_Rela*)(elfImage + sectionHeader[i].sh_offset))[index];
-					void *symbol = relocateSymbol(elfHeader, relocation, sectionHeader[i]);
+					relocateSymbol(elfHeader, relocation, sectionHeader[i]);
 				}
 			}
 		}
@@ -683,15 +687,6 @@
 		return createArithmetic(Ice::InstArithmetic::Xor, lhs, rhs);
 	}
 
-	static Ice::Variable *createAssign(Ice::Operand *constant)
-	{
-		Ice::Variable *value = ::function->makeVariable(constant->getType());
-		auto assign = Ice::InstAssign::create(::function, value, constant);
-		::basicBlock->appendInst(assign);
-
-		return value;
-	}
-
 	Value *Nucleus::createNeg(Value *v)
 	{
 		return createSub(createNullValue(T(v->getType())), v);