+ {
+ // Make sure we generate both values.
+ if (Result != 1)
+ ExprMap[N.getValue(1)] = 1; // Generate the token
+ else
+ Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType());
+
+ SDOperand Chain = N.getOperand(0);
+ SDOperand Address = N.getOperand(1);
+ Select(Chain);
+
+ switch (Node->getValueType(0)) {
+ default: assert(0 && "Cannot load this type!");
+ case MVT::i1:
+ case MVT::i8: Opc = PPC::LBZ; break;
+ case MVT::i16: Opc = PPC::LHZ; break;
+ case MVT::i32: Opc = PPC::LWZ; break;
+ }
+
+ if (Address.getOpcode() == ISD::GlobalAddress) { // FIXME
+ BuildMI(BB, Opc, 2, Result)
+ .addGlobalAddress(cast<GlobalAddressSDNode>(Address)->getGlobal())
+ .addReg(PPC::R1);
+ }
+ else if (ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(Address)) {
+ BuildMI(BB, Opc, 2, Result).addConstantPoolIndex(CP->getIndex())
+ .addReg(PPC::R1);
+ }
+ else if(Address.getOpcode() == ISD::FrameIndex) {
+ BuildMI(BB, Opc, 2, Result)
+ .addFrameIndex(cast<FrameIndexSDNode>(Address)->getIndex())
+ .addReg(PPC::R1);
+ } else {
+ int offset;
+ SelectAddr(Address, Tmp1, offset);
+ BuildMI(BB, Opc, 2, Result).addSImm(offset).addReg(Tmp1);
+ }
+ return Result;
+ }
+