<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">SUMMARY:<br>
This patch adds the <target>TargetMachine class <br>
object to the creation of the <target>MCAsmBackend<br>
class object.<br>
<br>
PROBLEM:<br>
The problem I have been having for some time is how<br>
to get access to target specific information during<br>
the direct object output phase. The current issue was<br>
how to fill the ELF header's target specific E_FLAGS<br>
bit field.<br>
<br>
SOLUTION:<br>
The information has already been collected and isolated<br>
by the <target>TargetMachine class object. This patch<br>
passes the const pointer to this class object to the <br>
<target>MCAsmBackend class object which in turn passes <br>
it to the <target>ELFObjectWriter class object which<br>
updates the E_FLAGS.<br>
<br>
This is the current creation routine for the backend:<br>
<br>
MCAsmBackend *llvm::createMipsAsmBackendEB64(const Target &T, StringRef TT,<br>
                                             StringRef CPU,<br>
                                             const TargetMachine *TM) {<br>
  return new MipsAsmBackend(T, Triple(TT).getOS(),<br>
                            /*IsLittle*/false, /*Is64Bit*/true, TM);<br>
}<br>
<br>
I believe we could reduce this to the one parameter TM <br>
and derive the rest of the information from it. I also<br>
believe that TM could be used with the other MC classes<br>
to reduce the need for future parameters there as well.<br>
<br>
An alternative and maybe cleaner solution would to create<br>
another class object, call it MCTarget for now, That would<br>
be filled at about the same time as SubtargetInfo and filled<br>
independently by the individual targets with just what they<br>
want. This might be more acceptable to the llvm-mc folks. I'd<br>
still want to load it with TM from a MCTarget method initially<br>
because the info is there.<br>
<br>
For now, TargetMachine/SubtargetInfo have already derived <br>
all that I need, albeit with a load of stuff I don't need<br>
as well.<br>
<br>
CAVEAT:<br>
llvm-mc and clang both create MCAsmBackend separate from<br>
the general mechanism. In this patch I pass 0 (NULL) and <br>
check for it before using the <target>TargetMachine object<br>
pointer. That is also why I use a pointer instead of a reference.<br>
<br>
This will be fixed in a later patch.<br>
<br>
CONCLUSION:<br>
* This patch does not affect the current behavior of other<br>
  targets.<br>
* Future E_FLAGS additions will be easy to implement at the<br>
  individual target level.<br>
* This change has changes in both the llvm and clang trees.<br>
* it would be followed up with patches for llvm-mc and clang.<br>
<br>
Contributer: Jack Carter<br>
<br>
</div>
</body>
</html>