Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright 2011 Christoph Bumiller
  3.  *           2014 Red Hat Inc.
  4.  *
  5.  * Permission is hereby granted, free of charge, to any person obtaining a
  6.  * copy of this software and associated documentation files (the "Software"),
  7.  * to deal in the Software without restriction, including without limitation
  8.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9.  * and/or sell copies of the Software, and to permit persons to whom the
  10.  * Software is furnished to do so, subject to the following conditions:
  11.  *
  12.  * The above copyright notice and this permission notice shall be included in
  13.  * all copies or substantial portions of the Software.
  14.  *
  15.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  18.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  19.  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  20.  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21.  * OTHER DEALINGS IN THE SOFTWARE.
  22.  */
  23.  
  24. #include "codegen/nv50_ir_target_gm107.h"
  25. #include "codegen/nv50_ir_lowering_gm107.h"
  26.  
  27. namespace nv50_ir {
  28.  
  29. Target *getTargetGM107(unsigned int chipset)
  30. {
  31.    return new TargetGM107(chipset);
  32. }
  33.  
  34. // BULTINS / LIBRARY FUNCTIONS:
  35.  
  36. // lazyness -> will just hardcode everything for the time being
  37.  
  38. #include "lib/gm107.asm.h"
  39.  
  40. void
  41. TargetGM107::getBuiltinCode(const uint32_t **code, uint32_t *size) const
  42. {
  43.    *code = (const uint32_t *)&gm107_builtin_code[0];
  44.    *size = sizeof(gm107_builtin_code);
  45. }
  46.  
  47. uint32_t
  48. TargetGM107::getBuiltinOffset(int builtin) const
  49. {
  50.    assert(builtin < NVC0_BUILTIN_COUNT);
  51.    return gm107_builtin_offsets[builtin];
  52. }
  53.  
  54. bool
  55. TargetGM107::isOpSupported(operation op, DataType ty) const
  56. {
  57.    switch (op) {
  58.    case OP_MAD:
  59.    case OP_FMA:
  60.       if (ty != TYPE_F32)
  61.          return false;
  62.       break;
  63.    case OP_SAD:
  64.    case OP_POW:
  65.    case OP_SQRT:
  66.    case OP_DIV:
  67.    case OP_MOD:
  68.       return false;
  69.    default:
  70.       break;
  71.    }
  72.  
  73.    return true;
  74. }
  75.  
  76. bool
  77. TargetGM107::runLegalizePass(Program *prog, CGStage stage) const
  78. {
  79.    if (stage == CG_STAGE_PRE_SSA) {
  80.       GM107LoweringPass pass(prog);
  81.       return pass.run(prog, false, true);
  82.    } else
  83.    if (stage == CG_STAGE_POST_RA) {
  84.       NVC0LegalizePostRA pass(prog);
  85.       return pass.run(prog, false, true);
  86.    } else
  87.    if (stage == CG_STAGE_SSA) {
  88.       NVC0LegalizeSSA pass;
  89.       return pass.run(prog, false, true);
  90.    }
  91.    return false;
  92. }
  93.  
  94. CodeEmitter *
  95. TargetGM107::getCodeEmitter(Program::Type type)
  96. {
  97.    return createCodeEmitterGM107(type);
  98. }
  99.  
  100. } // namespace nv50_ir
  101.