Ejemplo n.º 1
0
MipsABI::Type getMipsABI() {
#if LDC_LLVM_VER >= 307
  // eabi can only be set on the commandline
  if (strncmp(opts::mABI.c_str(), "eabi", 4) == 0)
    return MipsABI::EABI;
  else {
#if LDC_LLVM_VER >= 308
    const llvm::DataLayout dl = gTargetMachine->createDataLayout();
#else
    const llvm::DataLayout &dl = *gTargetMachine->getDataLayout();
#endif
    if (dl.getPointerSizeInBits() == 64)
      return MipsABI::N64;
    else if (dl.getLargestLegalIntTypeSize() == 64)
      return MipsABI::N32;
    else
      return MipsABI::O32;
  }
#else
  llvm::StringRef features = gTargetMachine->getTargetFeatureString();
  if (features.find("+o32") != std::string::npos) {
    return MipsABI::O32;
  }
  if (features.find("+n32") != std::string::npos) {
    return MipsABI::N32;
  }
  if (features.find("+n64") != std::string::npos) {
    return MipsABI::N32;
  }
  if (features.find("+eabi") != std::string::npos) {
    return MipsABI::EABI;
  }
  return MipsABI::Unknown;
#endif
}