/** \details * * Static method that sets register field * The register field is bit 8-11 of an instruction, which is where the 1st field for register operands * * Also sets the 1nd bit of RXB in case the 1st field is a VRF register */ void OMR::Z::RealRegister::setRegisterField(uint32_t *instruction,RegNum reg) { *instruction &= boi(0xFF0FFFFF); // clear out bit 8-11 of the instruction memory *instruction |= boi( (_fullRegBinaryEncodings[reg] & 0x0f) << 20); if (TR::RealRegister::isVRF(reg)) TR::RealRegister::setRegisterRXBField(instruction, reg, 1); // 1st register field }
/** \details * * Static Set Index Register Field. * The index register field corresponds to bit 12-15 of an instruction, which is * where the 2nd field for register operands * * Slso sets the 2nd bit of RXB in case bit 12-15 refers to an VRF register * */ void OMR::Z::RealRegister::setIndexRegisterField(uint32_t *instruction,RegNum reg) { *instruction &= boi(0xFFF0FFFF); // clear out bit 12-15 of the instruction memory *instruction |= boi( (_fullRegBinaryEncodings[reg] & 0x0f) << 16); if (TR::RealRegister::isVRF(reg)) TR::RealRegister::setRegisterRXBField(instruction, reg, 2); // index reg is in the 2nd register field }
/** \details * * Static method set base register field. * The 'base register field' corresponds to bit 16-19 of an instruction, which is * where the 3rd field for register operands * * Also sets the 3rd bit of RXB in case the 3rd field refers to a VRF register * */ void OMR::Z::RealRegister::setBaseRegisterField(uint32_t *instruction,RegNum reg) { *instruction &= boi(0xFFFF0FFF); // clear out bit 16-19 of the instruction memory *instruction |= boi( (_fullRegBinaryEncodings[reg] & 0x0f) << 12); if (TR::RealRegister::isVRF(reg)) TR::RealRegister::setRegisterRXBField(instruction, reg, 3); // base reg is in the 3rd register field }
/** \details * * Set register field with nibble */ void OMR::Z::RealRegister::setRegisterField(uint32_t *instruction, int32_t nibbleIndex,RegNum reg) { TR_ASSERT(nibbleIndex>=0 && nibbleIndex<=7, "OMR::Z::RealRegister::RealRegister: bad nibbleIndex\n"); uint32_t maskInstruction = *instruction&(0xF<<nibbleIndex*4); *instruction ^= boi(maskInstruction); // clear out the memory of byte *instruction |= boi((_fullRegBinaryEncodings[reg] & 0x0f) << nibbleIndex*4); }
// byte order big to little address (4 or 8 bytes) inline intptrj_t boa(intptrj_t arg) { if (sizeof(intptrj_t) == 4) return boi(arg); else return bol(arg); }
TEST(Optional, Comparisons) { Optional<int> o_; Optional<int> o1(1); Optional<int> o2(2); EXPECT_TRUE(o_ <= o_); EXPECT_TRUE(o_ == o_); EXPECT_TRUE(o_ >= o_); EXPECT_TRUE(o1 < o2); EXPECT_TRUE(o1 <= o2); EXPECT_TRUE(o1 <= o1); EXPECT_TRUE(o1 == o1); EXPECT_TRUE(o1 != o2); EXPECT_TRUE(o1 >= o1); EXPECT_TRUE(o2 >= o1); EXPECT_TRUE(o2 > o1); EXPECT_FALSE(o2 < o1); EXPECT_FALSE(o2 <= o1); EXPECT_FALSE(o2 <= o1); EXPECT_FALSE(o2 == o1); EXPECT_FALSE(o1 != o1); EXPECT_FALSE(o1 >= o2); EXPECT_FALSE(o1 >= o2); EXPECT_FALSE(o1 > o2); /* folly::Optional explicitly doesn't support comparisons with contained value EXPECT_TRUE(1 < o2); EXPECT_TRUE(1 <= o2); EXPECT_TRUE(1 <= o1); EXPECT_TRUE(1 == o1); EXPECT_TRUE(2 != o1); EXPECT_TRUE(1 >= o1); EXPECT_TRUE(2 >= o1); EXPECT_TRUE(2 > o1); EXPECT_FALSE(o2 < 1); EXPECT_FALSE(o2 <= 1); EXPECT_FALSE(o2 <= 1); EXPECT_FALSE(o2 == 1); EXPECT_FALSE(o2 != 2); EXPECT_FALSE(o1 >= 2); EXPECT_FALSE(o1 >= 2); EXPECT_FALSE(o1 > 2); */ // boost::optional does support comparison with contained value, which can // lead to confusion when a bool is contained boost::optional<int> boi(3); EXPECT_TRUE(boi < 5); EXPECT_TRUE(boi <= 4); EXPECT_TRUE(boi == 3); EXPECT_TRUE(boi != 2); EXPECT_TRUE(boi >= 1); EXPECT_TRUE(boi > 0); EXPECT_TRUE(1 < boi); EXPECT_TRUE(2 <= boi); EXPECT_TRUE(3 == boi); EXPECT_TRUE(4 != boi); EXPECT_TRUE(5 >= boi); EXPECT_TRUE(6 > boi); boost::optional<bool> bob(false); EXPECT_TRUE(bob); EXPECT_TRUE(bob == false); // well that was confusing EXPECT_FALSE(bob != false); }