reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
declare_args() {
  # The target archs LLVM should support. Defaults to the host arch.
  # Set to a list, e.g. `llvm_targets_to_build = [ "X86", "ARM" ]`,
  # or to the string "all" to get all known targets.
  llvm_targets_to_build = "host"
}

# FIXME: Port the remaining targets.
llvm_all_targets = [
  "AArch64",
  "AMDGPU",
  "ARM",
  "AVR",
  "BPF",
  "Hexagon",
  "Lanai",
  "Mips",
  "NVPTX",
  "PowerPC",
  "RISCV",
  "Sparc",
  "SystemZ",
  "WebAssembly",
  "X86",
]

if (llvm_targets_to_build == "host") {
  if (host_cpu == "arm64") {
    llvm_targets_to_build = [ "AArch64" ]
  } else if (host_cpu == "arm") {
    llvm_targets_to_build = [ "ARM" ]
  } else if (host_cpu == "ppc" || host_cpu == "ppc64") {
    llvm_targets_to_build = [ "PowerPC" ]
  } else if (host_cpu == "x86" || host_cpu == "x64") {
    llvm_targets_to_build = [ "X86" ]
  } else {
    assert(false, "add your host_cpu above")
  }
} else if (llvm_targets_to_build == "all") {
  llvm_targets_to_build = llvm_all_targets
}

# Validate that llvm_targets_to_build is set to a list of valid targets,
# and remember which targets are built where needed (for conditionally-built
# unittest targets).
llvm_build_AArch64 = false
llvm_build_ARM = false
llvm_build_BPF = false
llvm_build_Mips = false
llvm_build_PowerPC = false
llvm_build_WebAssembly = false
llvm_build_X86 = false
foreach(target, llvm_targets_to_build) {
  if (target == "AArch64") {
    llvm_build_AArch64 = true
  } else if (target == "ARM") {
    llvm_build_ARM = true
  } else if (target == "BPF") {
    llvm_build_BPF = true
  } else if (target == "Mips") {
    llvm_build_Mips = true
  } else if (target == "PowerPC") {
    llvm_build_PowerPC = true
  } else if (target == "WebAssembly") {
    llvm_build_WebAssembly = true
  } else if (target == "X86") {
    llvm_build_X86 = true
  } else if (target == "AMDGPU" || target == "AVR" || target == "Hexagon" ||
             target == "Lanai" || target == "NVPTX" || target == "RISCV" ||
             target == "Sparc" || target == "SystemZ") {
    # Nothing to do.
  } else {
    all_targets_string = ""
    foreach(target, llvm_all_targets) {
      all_targets_string += "$0x0a    " + target
    }
    assert(false, "Unknown target '$target' in llvm_targets_to_build. " +
                      "Known targets:" + all_targets_string)
  }
}

# FIXME: This should be based off target_cpu once cross compiles work.
if (host_cpu == "arm64") {
  native_target = "AArch64"
} else if (host_cpu == "arm") {
  native_target = "ARM"
} else if (host_cpu == "ppc" || host_cpu == "ppc64") {
  native_target = "PowerPC"
} else if (host_cpu == "x86" || host_cpu == "x64") {
  native_target = "X86"
} else {
  assert(false, "Unsuppored host_cpu '$host_cpu'.")
}