title: How to reimplement AsmPrinter in LLVM-Clang to generate my own directive set?
body: <p>I'm using LLVM and Clang to generate assembly listing from .c file. Instructions are printed correctly, but in the beginning and in the end LLVM-Clang inserts default directives incompatible with my architecture. I overrode AsmPrinter class to get own directives, but I succeeded only in adding new directives not in replacing them. For instance:</p>
  
  <p>MyAsmPrinter.c:</p>
  
  <pre><code>class MyAsmPrinter : public AsmPrinter { 
  ...
      void EmitStartOfAsmFile(Module &amp;M) override;
      void EmitEndOfAsmFile(Module &amp;M) override;
  ...
  }
  
  void MyAsmPrinter::EmitStartOfAsmFile(Module &amp;M) {
      &lt;--- insert something (A)
  }
  
  void MyAsmPrinter::EmitEndOfAsmFile(Module &amp;M) {
      &lt;--- insert something (B)
  }
  </code></pre>
  
  <p>clangtest.c:</p>
  
  <pre><code>int main() 
  {
    int a, b;
    b = 3;
    a = b*b;
    return a;
  }
  </code></pre>
  
  <p>I type:</p>
  
  <pre><code>./bin/clang -target mytarget -S clangtest.c -o test.s
  </code></pre>
  
  <p>And get</p>
  
  <pre><code>.text
  &lt;--- (A goes here)
  .file   "clangtest.c"
  .globl  main
  .type   main,@function
      main:
      (correct asm code here)
  .Ltmp0:
      .size   main, .Ltmp0-main
  
  
  .ident  "clang version 3.6.0 ..."
  .section    ".note.GNU-stack","",@progbits
  &lt;--- (B goes here)
  </code></pre>
  
  <p>But I want to get rid of ".text", ".file" and ".ident" at all. Where they get inserted anyway? I tried googling it, greping source code for other targets and LLVM source code, but found nothing. So, could anyone give me a hint how to do this?</p>