MCPcopy Create free account
hub / github.com/GJDuck/e9patch / sendLoadOperandMetadata

Function sendLoadOperandMetadata

src/e9tool/e9metadata.cpp:935–1072  ·  view source on GitHub ↗

* Emits instructions to load an operand into the corresponding * regno register. If the operand does not exist, load 0. */

Source from the content-addressed store, hash-verified

933 * regno register. If the operand does not exist, load 0.
934 */
935static bool sendLoadOperandMetadata(FILE *out, const char *name,
936 const InstrInfo *I, const OpInfo *op, bool ptr, FieldKind field,
937 CallInfo &info, int regno)
938{
939 if (field != FIELD_NONE)
940 {
941 const char *name = nullptr;
942 switch (field)
943 {
944 case FIELD_DISPL:
945 name = "displacement"; break;
946 case FIELD_BASE:
947 name = "base"; break;
948 case FIELD_INDEX:
949 name = "index"; break;
950 case FIELD_SCALE:
951 name = "scale"; break;
952 case FIELD_SIZE:
953 name = "size"; break;
954 case FIELD_TYPE:
955 name = "type"; break;
956 case FIELD_ACCESS:
957 name = "access"; break;
958 default:
959 name = "???"; break;
960 }
961 switch (field)
962 {
963 case FIELD_DISPL: case FIELD_BASE: case FIELD_INDEX:
964 case FIELD_SCALE:
965 if (op->type != OPTYPE_MEM)
966 {
967 warning(CONTEXT_FORMAT "failed to load %s into register "
968 "%s; cannot load %s of non-memory operand",
969 CONTEXT(I), name, getRegName(getReg(regno)), name);
970 sendSExtFromI32ToR64(out, 0, regno);
971 return false;
972 }
973 break;
974 default:
975 break;
976 }
977 switch (field)
978 {
979 case FIELD_DISPL:
980 sendLoadValueMetadata(out, op->mem.disp, regno);
981 return true;
982 case FIELD_BASE:
983 if (op->mem.base == REGISTER_NONE)
984 {
985 warning(CONTEXT_FORMAT "failed to load memory operand "
986 "base into register %s; operand does not use a base "
987 "register", CONTEXT(I), getRegName(getReg(regno)));
988 sendSExtFromI32ToR64(out, 0, regno);
989 return false;
990 }
991 return sendLoadRegToArg(out, I, op->mem.base, ptr, info,
992 regno);

Callers 1

sendLoadArgumentMetadataFunction · 0.85

Calls 8

warningFunction · 0.85
getRegFunction · 0.85
sendSExtFromI32ToR64Function · 0.85
sendLoadValueMetadataFunction · 0.85
sendLoadRegToArgFunction · 0.85
errorFunction · 0.85
sendLoadFromMemOpToR64Function · 0.85
sendLeaFromPCRelToR64Function · 0.85

Tested by

no test coverage detected